---L---- ------M------- N O -P-- -Q- -R- -S-
4 Expected value
5 5.408609321 Size 100
6
7
8 1 2 3 80% 90% 95%
9 0.013522 0 0 1 2 2
10 0.013522 0 0 1 2 2
11 0.013522 0 0 1 2 2
12 0.027043 0 0 3 4 5
13 0.054086 0 0 6 7 8
The formula in Q9 and copied right and down is
=PoissonInv(Q$8,$Q$5*$L9)
Function PoissonInv(dVal As Double, dMean As Double) As Variant
' shg 2011
' For a Poisson process with mean dMean, returns the largest
' integer N such that POISSON(N, dMean, True) <= dVal
' E.g., POISSON(5, 10, TRUE) returns 0.0670859629
' PoissonInv(0.0670859629, 10) returns 5
' Returns #VALUE! if dVal < 0 or dVal >= 1
' Returns -1 if dVal < POISSON(0, dMean, TRUE)
Dim iX As Long ' number of events
Dim dCDF As Double ' cumulative distribution function of iX
' these variables are used to simplify this summation:
' dCDF = dCDF + Exp(-dMean) * dMean ^ iX / .Fact(iX)
Dim dExpMean As Double ' =Exp(-dMean)
Dim dFact As Double ' incremental factorial
Dim dPowr As Double ' incremental power
If dVal < 0 Or dVal >= 1 Then
PoissonInv = CVErr(xlErrValue)
ElseIf dVal > 0 Then
dExpMean = Exp(-dMean)
dFact = 1
dPowr = 1
Do While dCDF < dVal
dCDF = dCDF + dExpMean * dPowr / dFact
iX = iX + 1
dFact = dFact * iX
dPowr = dPowr * dMean
Loop
PoissonInv = iX - IIf(dCDF / dVal > 1.000000000001, 2, 1)
End If
End Function
Bookmarks