[Scipy-tickets] [SciPy] #620: scipy.stats.distributions.binom.pmf returns incorrect values

SciPy scipy-tickets@scipy....
Mon Dec 8 03:24:06 CST 2008


#620: scipy.stats.distributions.binom.pmf returns incorrect values
----------------------------+-----------------------------------------------
 Reporter:  robertbjornson  |        Owner:  josefpktd
     Type:  defect          |       Status:  new      
 Priority:  normal          |    Milestone:  0.8      
Component:  scipy.stats     |      Version:           
 Severity:  normal          |   Resolution:           
 Keywords:                  |  
----------------------------+-----------------------------------------------
Comment (by pbrod):

 I have compared the implementations above and it seems that Loader's
 algorithm is more accurate for large n as exemplified here:
 {{{
 In [73]: import scipy.stats as st
 In [63]: n=1000;p=1.0e-5

 In [64]: pmfnln = bpmfln(np.arange(n+1),n, p)

 In [65]: pmfnln1 =st.distributions.binom.pmf(np.arange(n+1),n, p)

 In [66]: sum(pmfnln)-1,sum(pmfnln1)-1
 Out[66]: (9.7699626167013776e-015, 0.0)

 In [67]: n=10000

 In [68]: pmfnln1 =st.distributions.binom.pmf(np.arange(n+1),n, p)

 In [69]: pmfnln = bpmfln(np.arange(n+1),n, p)

 In [70]: sum(pmfnln)-1,sum(pmfnln1)-1
 Out[70]: (4.5563552930616424e-013, -1.1102230246251565e-016)

 In [74]: n=50000

 In [75]: pmfnln1 =st.binom.pmf(np.arange(n+1),n, p)

 In [76]: pmfnln = bpmfln(np.arange(n+1),n, p)

 In [77]: sum(pmfnln)-1,sum(pmfnln1)-1
 Out[77]: (2.1761925594887543e-011, -1.1102230246251565e-016)

 In [78]: n=100000

 In [79]: pmfnln1 =st.distributions.binom.pmf(np.arange(n+1),n, p)

 In [80]: pmfnln = bpmfln(np.arange(n+1),n, p)

 In [81]: sum(pmfnln)-1,sum(pmfnln1)-1
 Out[81]: (-3.095634859562324e-011, 0.0)
 }}}

-- 
Ticket URL: <http://scipy.org/scipy/scipy/ticket/620#comment:6>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list