[SciPy-Dev] binom_test incorrect behavior in the tails

Yaroslav Halchenko lists@onerussian....
Wed Mar 16 13:50:49 CDT 2011


probably due to incorrect pmf computation (which should be symmetric for
p=0.5, but it isn't):

In [78]: 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.96152397e-08   5.78398085e-09   1.61072888e-09
   4.22816337e-10   1.04399045e-10   2.41900944e-11   5.24602584e-12
   1.06170628e-12   1.99840144e-13   3.48610030e-14   5.55111512e-15
   8.88178420e-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.11022302e-16]
[ -1.11022302e-16   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
  -5.95423185e-17   5.81138699e-17  -3.65137385e-18   8.67140393e-18
  -9.44431785e-18   5.57974827e-18  -6.06218405e-17   4.80626902e-17
  -1.07373643e-17  -1.97571409e-17   7.03550182e-17  -1.24116201e-17
  -2.13170664e-17  -2.03950711e-17  -1.61294131e-17   1.02130998e-18
  -1.29934854e-18   4.42998231e-18   2.52619106e-17  -4.68239813e-17
   4.14707331e-17  -2.22261445e-17   6.02816408e-17   1.51788304e-18
  -3.98986399e-17   2.08166817e-17  -3.46944695e-18   1.38777878e-17
  -7.97972799e-17   8.67361738e-17  -4.85722573e-17   2.77555756e-17
   1.38777878e-17  -2.77555756e-17   2.77555756e-17  -8.32667268e-17
   1.11022302e-16  -5.55111512e-17   0.00000000e+00   5.55111512e-17
  -1.11022302e-16   8.32667268e-17  -2.77555756e-17   2.77555756e-17
  -1.38777878e-17  -2.77555756e-17   4.85722573e-17  -8.67361738e-17
   7.97972799e-17  -1.38777878e-17   3.46944695e-18  -2.08166817e-17
   3.98986399e-17  -1.51788304e-18  -6.02816408e-17   2.22261445e-17
  -4.14707331e-17   4.68239813e-17  -2.52619106e-17  -4.42998231e-18
   1.29934854e-18  -1.02130998e-18   1.61294131e-17   2.03950711e-17
   2.13170664e-17   1.24116201e-17  -7.03550182e-17   1.97571409e-17
   1.07373643e-17  -4.80626902e-17   6.06218405e-17  -5.57974827e-18
   9.44431785e-18  -8.67140393e-18   3.65137385e-18  -5.81138699e-17
   5.95423185e-17  -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
   1.11022302e-16]

On Wed, 16 Mar 2011, Yaroslav Halchenko wrote:

> I am using scipy 0.7.2 in Debian

> could anyone check if following behavior is still in place in the
> current master:

> $> python -c 'import scipy.stats,numpy; print numpy.array([scipy.stats.binom_test(a, 100) for a in [90, 98, 99, 100]])' 
> [  1.53164509e-17   1.60428187e-19   1.66102449e-18   2.16868332e-09]   
-- 
=------------------------------------------------------------------=
Keep in touch                                     www.onerussian.com
Yaroslav Halchenko                 www.ohloh.net/accounts/yarikoptic


More information about the SciPy-Dev mailing list