[SciPy-User] log pdf, cdf, etc
John Reid
j.reid at mail.cryst.bbk.ac.uk
Sat May 29 12:18:07 EDT 2010
josef.pktd at gmail.com wrote:
> On Fri, May 28, 2010 at 7:29 AM, Chris Strickland
> <christophermarkstrickland at gmail.com> wrote:
>> Hi,
>>
>> When using any of the distributions of scipy.stats there does not seem to be
>> the ability (or at least I cannot figure out how) to have the function
>> return
>> the log of the pdf, cdf, sf, etc. For statistical analysis this is
>> essential.
>> For instance suppose we are interested in an exponential distribution for a
>> random variable x with a hyperparameter lambda there needs to be an option
>> that returns -log(lambda)-x/lambda. It is not sufficient (numerically) to
>> calculate log(scipy.stats.expon.pdf(x,lambda)).
>>
>> Is there a way to do this using the distributions in scipy.stats?
>
> It would need a new method for each distribution, e.g. _loglike, _logpdf
> So, this is work, and for some distributions the log wouldn't simplify much.
Presumably it would be easy to add a method to all distributions that
called the pdf and took its log. This could be over-riden for those
distributions for which a specialised log_pdf implementation was
available. This would make the entry cost of providing the functionality
lower.
More information about the SciPy-User
mailing list