[Numpy-tickets] [NumPy] #923: numpy.random.logseries - incorrect convergence for k=1, k=2

NumPy numpy-tickets@scipy....
Fri Dec 12 00:18:04 CST 2008


#923: numpy.random.logseries - incorrect convergence for k=1, k=2
--------------------------+-------------------------------------------------
 Reporter:  josefpktd     |        Owner:  somebody
     Type:  defect        |       Status:  new     
 Priority:  normal        |    Milestone:          
Component:  numpy.random  |      Version:  none    
 Severity:  normal        |   Resolution:          
 Keywords:                |  
--------------------------+-------------------------------------------------
Comment (by josefpktd):

 I compiled numpy with this fix and it seems to work in initial examples,
 still need to run full tests. Here's the diff:

 {{{
 Index: c:/Josef/_progs/Subversion/numpy-
 trunk/numpy/random/mtrand/distributions.c
 ===================================================================
 --- c:/Josef/_progs/Subversion/numpy-
 trunk/numpy/random/mtrand/distributions.c  (revision 6139)
 +++ c:/Josef/_progs/Subversion/numpy-
 trunk/numpy/random/mtrand/distributions.c  (working copy)
 @@ -868,7 +868,7 @@
                  return result;
              }
          }
 -        if (V <= q) {
 +        if (V >= q) {
              return 1;
          }
          return 2;
 }}}

 some results:

 {{{
 >>> pr=0.8
 >>> N=100000
 >>> rvsn=np.random.logseries(pr,size=N)
 >>> print np.sum(rvsn==1)/float(N)
 0.49622
 >>> print np.sum(rvsn==2)/float(N)
 0.19899
 >>> print np.sum(rvsn==3)/float(N)
 0.1067
 >>> print np.sum(rvsn==4)/float(N)
 0.06323
 >>> stats.logser.pmf([0,1,2,3,4],pr)
 array([ 0.        ,  0.49706795,  0.19882718,  0.10604116,  0.0636247 ])

 }}}

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/923#comment:4>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list