[SciPy-User] speed of logpdf functions in scipy.stats

Robert Kern robert.kern at gmail.com
Sat Mar 28 13:14:48 EDT 2015


On Sat, Mar 28, 2015 at 5:01 PM, Brian Blais <bblais at gmail.com> wrote:
>
> On Sat, Mar 28, 2015 at 7:35 AM, Robert Kern <robert.kern at gmail.com>
wrote:
> >
> > He meant norm._logpdf(x).
> >
>
> ah, that makes more sense....and it's faster than my python function.
> however, this clearly works only in the case of mu=0, sd=1.  for the
> normal it's easy to transform, but my goal is to have fast version of
> the logpdf's of the different scipy.stats distributions, where each
> call may have *different* distribution parameters.  is there a fast
> _logpdf-type version for the distributions where you can specify
> value, scale, etc...?

The difference in overhead between norm.logpdf() and norm._logpdf() is
mostly just taking care of the location and scale parameters. It's the same
for every distribution, which is why we have it organized this way. There
is perhaps a little more overhead than strictly necessary because it needs
to handle the generic argument manipulation for those distributions that
take shape parameters in addition to location and scale. If you want to
write a bunch of repetitive boilerplate to do the location and scale
manipulation for each distribution separately, that is likely the only way
to improve on the overhead.

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150328/513f9da3/attachment.html>


More information about the SciPy-User mailing list