[Scipy-tickets] [SciPy] #1865: scipy.stats.binom_test gives undesired results when x is first above n/2

SciPy Trac scipy-tickets@scipy....
Wed Mar 13 09:21:06 CDT 2013


#1865: scipy.stats.binom_test gives undesired results when x is first above n/2
----------------------+-----------------------------------------------------
 Reporter:  vvanasch  |       Owner:  somebody   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  Other     |     Version:  0.11.0     
 Keywords:            |  
----------------------+-----------------------------------------------------
 In R and by hand the two-sided binomial test Bin(5, 0.5) gives a
 probability of 1 for x=3. This is not the case for binom_test.

 It incorrectly returns:
 > scipy.stats.binom_test(3, 5, 0.5)
 0.6875

 This can be solved by changing line 1045 of morestats.py (Scipy version
 0.12b1) from:

 > i = np.arange(np.floor(p*n))

 to

 > i = np.arange(np.ceil(p*n))

 With this adjustment binom_test behaves the same as binom.test(3,5,0.5) in
 R

 and also

 scipy.stats.binom_test(3, 5, 0.5) == scipy.stats.binom_test(2, 5, 0.5)

 as should be the case.

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


More information about the Scipy-tickets mailing list