[Scipy-tickets] [SciPy] #1131: Scipy Stats ppf for Lognormal fails on array-like 'loc' or 'scale'

SciPy Trac scipy-tickets@scipy....
Wed Mar 17 12:01:11 CDT 2010


#1131: Scipy Stats ppf for Lognormal fails on array-like 'loc' or 'scale'
---------------------------------------------------+------------------------
 Reporter:  catintp                                |       Owner:  somebody    
     Type:  defect                                 |      Status:  needs_review
 Priority:  normal                                 |   Milestone:  0.8.0       
Component:  scipy.stats                            |     Version:  0.7.0       
 Keywords:  ppf, parameters, loc, scale, mismatch  |  
---------------------------------------------------+------------------------

Comment(by josefpktd):

 Here is a better example to test the boundary behavior

 {{{
 >>> stats.truncnorm.ppf([-0.5,0,1e-4,0.5, 1-1e-4,1,2],-1., 1.,
 loc=3,scale=2)
 array([        NaN,  1.        ,  1.00056419,  3.        ,  4.99943581,
         5.        ,         NaN])

 incorrect result:
 >>> stats.truncnorm.isf([-0.5,0,1e-4,0.5, 1-1e-4,1,2],-1., 1.,
 loc=3,scale=2)
 array([        NaN,  1.        ,  4.99943581,  3.        ,  1.00056419,
        -1.        ,         NaN])
 }}}

 {{{
 >>> stats.truncnorm.isf([-0.5,0,1e-4,0.5, 1-1e-4,1,2],-1., 1.,
 loc=[3]*7,scale=2)
 array([        NaN,  1.        ,  4.99943581,  3.        ,  1.00056419,
        -1.        ,         NaN])
 >>> stats.truncnorm.ppf([-0.5,0,1e-4,0.5, 1-1e-4,1,2],-1., 1.,
 loc=[3]*7,scale=2)
 Traceback (most recent call last):
   File "c:\josef\_progs\subversion\scipy-
 trunk_after\trunk\dist\scipy-0.8.0.dev6156.win32\programs\python25\lib
 \site-packages\scipy\stats\distributions.py", line 718, in ppf
     output = valarray(shape(cond),value=self.a*scale + loc)
   File "c:\josef\_progs\subversion\scipy-
 trunk_after\trunk\dist\scipy-0.8.0.dev6156.win32\programs\python25\lib
 \site-packages\scipy\stats\distributions.py", line 235, in valarray
     out = reshape(repeat([value],product(shape,axis=0),axis=0),shape)
   File "C:\Programs\Python25\lib\site-packages\numpy\core\fromnumeric.py",
 line 152, in reshape
     return reshape(newshape, order=order)
 ValueError: total size of new array must be unchanged
 }}}

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


More information about the Scipy-tickets mailing list