[SciPy-Dev] binom_test incorrect behavior in the tails

Fernando Perez fperez.net@gmail....
Wed Mar 16 13:52:02 CDT 2011


On Wed, Mar 16, 2011 at 11:50 AM, Yaroslav Halchenko
<lists@onerussian.com> wrote:
> probably due to incorrect pmf computation (which should be symmetric for
> p=0.5, but it isn't):

and the same thing off master:

In [5]: pmfs = scipy.stats.binom.pmf(numpy.arange(0,101), 100, 0.5);
print pmfs; print pmfs - pmfs[::-1]
[  7.88860905e-31   7.88860905e-29   3.90486148e-27   1.27558808e-25
   3.09330110e-24   5.93913812e-23   9.40363535e-22   1.26277389e-20
   1.46797465e-19   1.50059631e-18   1.36554264e-17   1.11726216e-16
   8.28636101e-16   5.60922899e-15   3.48573516e-14   1.99848816e-13
   1.06169683e-12   5.24603142e-12   2.41900338e-11   1.04399093e-10
   4.22816327e-10   1.61072886e-09   5.78398092e-09   1.96152396e-08
   6.29322272e-08   1.91313971e-07   5.51867223e-07   1.51252498e-06
   3.94336870e-06   9.79043264e-06   2.31706906e-05   5.23209142e-05
   1.12816971e-04   2.32471335e-04   4.58105277e-04   8.63855666e-04
   1.55973940e-03   2.69792760e-03   4.47287998e-03   7.11073227e-03
   1.08438667e-02   1.58690732e-02   2.22922695e-02   3.00686426e-02
   3.89525598e-02   4.84742966e-02   5.79583981e-02   6.65905000e-02
   7.35270104e-02   7.80286641e-02   7.95892374e-02   7.80286641e-02
   7.35270104e-02   6.65905000e-02   5.79583981e-02   4.84742966e-02
   3.89525598e-02   3.00686426e-02   2.22922695e-02   1.58690732e-02
   1.08438667e-02   7.11073227e-03   4.47287998e-03   2.69792760e-03
   1.55973940e-03   8.63855666e-04   4.58105277e-04   2.32471335e-04
   1.12816971e-04   5.23209142e-05   2.31706906e-05   9.79043264e-06
   3.94336870e-06   1.51252498e-06   5.51867223e-07   1.91313971e-07
   6.29322272e-08   1.96152396e-08   5.78398092e-09   1.61072886e-09
   4.22816327e-10   1.04399093e-10   2.41900338e-11   5.24603142e-12
   1.06169683e-12   1.99848816e-13   3.48573516e-14   5.60922899e-15
   8.28636101e-16   1.11726216e-16   1.36554264e-17   1.50059631e-18
   1.46797465e-19   1.26277389e-20   9.40363535e-22   5.93913812e-23
   3.09330110e-24   1.27558808e-25   3.90486148e-27   7.88860905e-29
   7.88860905e-31]
[  0.00000000e+00   0.00000000e+00  -2.72636629e-41   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00  -9.70668692e-32   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   5.79026429e-24   0.00000000e+00   0.00000000e+00
  -2.24993127e-22  -6.88214270e-22   0.00000000e+00   0.00000000e+00
   1.35525272e-20   3.38813179e-20   0.00000000e+00   0.00000000e+00
  -4.06575815e-19   0.00000000e+00   0.00000000e+00   3.03576608e-18
   5.63785130e-18   0.00000000e+00   0.00000000e+00  -2.51534904e-17
  -3.81639165e-17   0.00000000e+00   0.00000000e+00   1.07552856e-16
   1.38777878e-16   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
  -1.38777878e-16  -1.07552856e-16   0.00000000e+00   0.00000000e+00
   3.81639165e-17   2.51534904e-17   0.00000000e+00   0.00000000e+00
  -5.63785130e-18  -3.03576608e-18   0.00000000e+00   0.00000000e+00
   4.06575815e-19   0.00000000e+00   0.00000000e+00  -3.38813179e-20
  -1.35525272e-20   0.00000000e+00   0.00000000e+00   6.88214270e-22
   2.24993127e-22   0.00000000e+00   0.00000000e+00  -5.79026429e-24
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   9.70668692e-32   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   2.72636629e-41   0.00000000e+00
   0.00000000e+00]

In [6]:


cheers

f


More information about the SciPy-Dev mailing list