[Scipy-svn] r4787 - in trunk/scipy/stats: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Oct 9 01:27:01 EDT 2008


Author: peridot
Date: 2008-10-09 00:26:59 -0500 (Thu, 09 Oct 2008)
New Revision: 4787

Modified:
   trunk/scipy/stats/distributions.py
   trunk/scipy/stats/tests/test_distributions.py
Log:
Fixed and installed tests for scipy.stats.vonmises. Closes tickets #747, #748, and #749.


Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py	2008-10-06 11:49:39 UTC (rev 4786)
+++ trunk/scipy/stats/distributions.py	2008-10-09 05:26:59 UTC (rev 4787)
@@ -3083,10 +3083,7 @@
     def _rvs(self, b):
         return mtrand.vonmises(0.0, b, size=self._size)
     def _pdf(self, x, b):
-        x = arr(angle(exp(1j*x)))
-        Px = where(b < 100, exp(b*cos(x)) / (2*pi*special.i0(b)),
-                   norm.pdf(x, 0.0, sqrt(1.0/b)))
-        return Px
+        return exp(b*cos(x)) / (2*pi*special.i0(b))
     def _cdf(self, x, b):
         x = arr(angle(exp(1j*x)))
         eps2 = sqrt(eps)
@@ -3102,7 +3099,7 @@
         vals = ones(len(c_xsimple),float)
         putmask(vals, c_bad, nan)
         putmask(vals, c_xsimple, x / 2.0/pi)
-        st = sqrt(b-0.5)
+        st = 1./sqrt(b-0.5)
         st = where(isnan(st),0.0,st)
         putmask(vals, c_xnormal, norm.cdf(x, scale=st))
 
@@ -3120,7 +3117,8 @@
             if (j == 500):
                 print "Warning: did not converge..."
             put(vals, indxiter, val)
-        return vals + 0.5
+        vals[c_xiter]+=0.5
+        return numpy.clip(vals,0,1)
     def _stats(self, b):
         return 0, None, 0, None
 vonmises = vonmises_gen(name='vonmises', longname="A Von Mises",

Modified: trunk/scipy/stats/tests/test_distributions.py
===================================================================
--- trunk/scipy/stats/tests/test_distributions.py	2008-10-06 11:49:39 UTC (rev 4786)
+++ trunk/scipy/stats/tests/test_distributions.py	2008-10-09 05:26:59 UTC (rev 4787)
@@ -33,7 +33,8 @@
          'halflogistic','fatiguelife','foldnorm','ncx2','t','nct',
          'weibull_min','weibull_max','dweibull','maxwell','rayleigh',
          'genlogistic', 'logistic','gumbel_l','gumbel_r','gompertz',
-         'hypsecant', 'laplace', 'reciprocal','triang','tukeylambda']
+         'hypsecant', 'laplace', 'reciprocal','triang','tukeylambda',
+         'vonmises']
 
 # check function for test generator
 def check_distribution(dist, args, alpha):
@@ -63,6 +64,9 @@
             vals = rand(nargs)
             vals[1] = vals[0] + 1.0
             args = tuple(vals)
+        elif dist == 'vonmises':
+            yield check_distribution, dist, (100,), alpha
+            args = tuple(1.0+rand(nargs))
         else:
             args = tuple(1.0+rand(nargs))
         yield check_distribution, dist, args, alpha




More information about the Scipy-svn mailing list