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

SciPy Trac scipy-tickets@scipy....
Wed Mar 17 11:43:58 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):

 thanks Charles,

 I have problems applying patches, so full files or functions are fine with
 me.
 I will review it soon.

 After a brief look at your changed function, I'm wondering why the
 (difficult) handling of scale and loc is necessary. isf seems to work and
 does not require much extra loc,scale handling.

 Ok, I briefly checked an example with isf again, and isf is wrong at the
 boundary (ppf at one and maybe zero for distributions with finite upper
 bound)

 {{{
 >>> stats.lognorm.isf([-0.5,0,1e-4,0.5,1-1e-4,1,2],0.5,loc=3,scale=1)
 array([        NaN,         Inf,  9.42057863,  4.        ,  3.1557492 ,
         0.        ,         NaN])
 >>> stats.lognorm.isf([-0.5,0,1e-4,0.5,1-1e-4,1,2],0.5,loc=3,scale=2)
 array([         NaN,          Inf,  15.84115726,   5.        ,
          3.3114984 ,   0.        ,          NaN])
 }}}

 instead of zero in the answer there should be 3 (=loc)

 I also need to see, why the tests don't cover this case.

 So it looks like the correction will have to be in the style of your
 patch.

 A thought:
 But there are still other parts to check (and to add tests), e.g. is the
 integration for _munp (generic moment calculation) correct if self.a and
 self.b do not take the location into account. The bug that you found might
 be symptomatic of a gap in the test coverage and problems with boundaries.
 (?)
 maybe it's not a problem: moment doesn't allow loc as argument, stats does
 the loc, scale correction for mean and variance directly and _munp only
 calculates moment for standard distribution. Need to check: is kurtosis
 scale independent?

 BTW: fixing bugs in stats.distributions is how I got started with scipy

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


More information about the Scipy-tickets mailing list