[Scipy-tickets] [SciPy] #749: scipy.stats.vonmises.cdf broken for large b

SciPy scipy-tickets@scipy....
Wed Oct 8 17:14:53 CDT 2008


#749: scipy.stats.vonmises.cdf broken for large b
---------------------+------------------------------------------------------
 Reporter:  peridot  |       Owner:  somebody
     Type:  defect   |      Status:  new     
 Priority:  normal   |   Milestone:          
Component:  Other    |     Version:          
 Severity:  normal   |    Keywords:          
---------------------+------------------------------------------------------
 scipy.stats.vonmises implements the von Mises distribution, a circular
 probability distribution defined on -pi to pi, resembling a Gaussian. This
 distribution is a function of b, the "concentration" parameter; for large
 values of b the von Mises distribution resembles a Gaussian.

 However:

 In [63]: scipy.stats.vonmises(99.999).cdf(-np.pi*0.99)
 Out[63]: array(0.0022649306320711715)

 In [64]: scipy.stats.vonmises(100).cdf(-np.pi*0.99)
 Out[64]: array(0.87759696699397516)

 Not only is this a rather alarming discontinuity, the value for b=100 is
 not even reasonable.

 This problem arises because in scipy/stats/distributions.py the von Mises
 distribution is defined with a switch: if b>=100, values for a normal
 distribution are returned. Unfortunately, the von Mises distribution is
 not tested at all in tests/test_distributions.py, and there is are two
 outright bugs in the CDF implementation. Specifically, the "scale"
 parameter of scipy.stats.norm.cdf is misapplied (the quantity is the
 reciprocal of the correct value), and 0.5 is incorrectly added to the
 result.

 The reason for this switch is because the CDF for the von Mises
 distribution is computed using a series, which converges rather slowly for
 large b. In fact, the implementation begins to become inaccurate on a
 scale of 10**-3 by b=70, so a fix should also change the transition from
 b=100 to b=70.

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


More information about the Scipy-tickets mailing list