Excel 2000 error in Poisson function

J

John Baker

Knowledge base article 828130 describes bug in Excel
calculation of Poisson. Does anyone have a simple way to
compute Poisson for values 100 to 2000 and 1000, like
Poisson(200,1000,false)?

It seems like Microsoft may not be planning on fixing the
bug for Excel 2000 and for Mac OSX, only for Excel 2003.
 
H

Harlan Grove

John Baker said:
Knowledge base article 828130 describes bug in Excel
calculation of Poisson. Does anyone have a simple way to
compute Poisson for values 100 to 2000 and 1000, like
Poisson(200,1000,false)?

It seems like Microsoft may not be planning on fixing the
bug for Excel 2000 and for Mac OSX, only for Excel 2003.

Checking the Google Groups archives is always a good idea as a first step.

http://groups.google.com/groups?selm=3FC56FCD.2010203@no_e-mail.com
 
J

Jerry W. Lewis

At the risk of beating a dead horse, since

Poisson(x,mean,TRUE) = ChiDist(2*mean,2*(x+1))

as noted in the referenced article, it follows that

Poisson(x,mean,FALSE) = ChiDist(2*mean,2*(x+1)) - ChiDist(2*mean,2*x)

The relationship is mathematically exact, but not numerically exact.

As the OP doubtless already knows, the pre-2003 Poisson() function
returns #NUM! for mean=1000 and x>102 (and incorrectly returns zero for
86<=x<=102). Here the ChiDist cumulative equivalent gives at least 7
figure accuracy, where it returns a value at all, but it also returns
#NUM! for 1000<=x<=1084, which corresponds to cumulative probabilities
between 0.50 and 0.996. The ChiDist non-cumulative equivalent gives at
least 5-figure accuracy, where it returns a value at all, except for
x=86, which only gives 1 figure accuracy. The loss of accuracy for for
the non-cumulative form is due to cancellation of significant figures in
the subtraction.

Lack of coverage for cumulative probabilities between 0.50 and 0.996
seems to me like a rather serious hole in the ChiDist function. You
could use the normal approximation, or you could improve on it with the
Wilson-Hilferty approximation or by adding various terms of the
Edgeworth expansion (consult Abramowitz and Stegun's "Handbook of
Mathematical Functions" or Johnson and Kotz's "Continuous Univariate
Distributions" for details).

As noted in the referenced article, none of these will beat Ian Smith's
VBA code at http://members.aol.com/iandjmsmith/Examples.xls

Jerry
 
D

Dana DeLouis

I'm not an expert, but would this work for you?

Function Poisson(n, mean)
'// Dana DeLouis
Poisson = Exp(-mean + n * Log(mean) - WorksheetFunction.GammaLn(1 + n))
End Function


Sub Test()
'Example in help (same answer)
Debug.Print Poisson(2, 5)

'Mathematica says error is about -1.0328206208905514*^-22
Debug.Print Poisson(800, 1000)
End Sub
 
I

Ian Smith

Dana DeLouis said:
I'm not an expert, but would this work for you?

Function Poisson(n, mean)
'// Dana DeLouis
Poisson = Exp(-mean + n * Log(mean) - WorksheetFunction.GammaLn(1 + n))
End Function


Sub Test()
'Example in help (same answer)
Debug.Print Poisson(2, 5)

'Mathematica says error is about -1.0328206208905514*^-22
Debug.Print Poisson(800, 1000)
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =
[snip]
The relative error is approx 1e-10 for Poisson(2, 5) and 1e-11 for
Poisson(800, 1000). By the time the arguments are about 1e6 the
relative error is usually no worse than 5e-9. In general, the relative
error will be no worse than 5e-16*mean.

If you want to use this code all you have to do is remember the
accuracy is no good for large values. If you offer this code to other
people all you have to do is tell them the accuracy is no good for
large values.

If you don't want to explain to users what the accuracy problems are,
then
http://groups.google.co.uk/[email protected]
has an example of how to avoid the errors induced by using functions
which evaluate the log of the gamma function.

Ian Smith
 
D

Dana DeLouis

Thanks Ian. You are correct, and I should have known that. I thought about
that right after I hit send, but was hoping nobody would catch it. :>)
Thanks for the link also. I see that this was already discussed. That was
an interesting discussion.
I was studying the ChiDist example from Jerry. I was trying to prove some
results using Mathematica (just for my own study), but am not having any
luck. I think I am missing a key idea somewhere.

....Oppps. As I was typing this, you gave me an idea.

Ok, it's off topic, but this is good for me. In Excel, =CHIDIST(2,5)
returns 0.849145038989397. I just realized that Excel's ChiDist is
returning the area of the tail to the right. Mathematica is returning the
area to the left. I just have to subtract 1 to get the same results as
Excel.

1 - CDF[ChiSquareDistribution[5],2]
0.8491450360846096

Ok. Now I get it.
Thanks again. :>)
--
Dana


<Useless information just for me>

excel = Poisson(2, 5)
0.0842243374986853
excel - PDF[PoissonDistribution[5], 2]

1.011E-11
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top