Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log pdf support? #525

Closed
Svalorzen opened this issue Feb 9, 2021 · 5 comments · Fixed by #762
Closed

Log pdf support? #525

Svalorzen opened this issue Feb 9, 2021 · 5 comments · Fixed by #762

Comments

@Svalorzen
Copy link

I was wondering whether there is, or there are plans to add, an interface to compute the logpdfs to the random distributions.

This would allow to more accurately manipulate probabilities without the need to first apply a log function to the output of the pdf and cdf functions.

@HDembinski
Copy link
Contributor

HDembinski commented Feb 15, 2022

+1 on this. When using the log-likelihood method, you need the logpdf instead of the pdf. Many common distributions are of the exponential family, so the logpdf is calculated naturally internally, and code that computes the log-likelihood then effectively does the superfluous log(exp(logpdf)).

The logpdf is also needed when the log-likelihood method is applied to additive models of the form pdf = z pdf_A + (1-z) pdf_B. There is a numerically stable way to compute log(exp(x1) + exp(x2)) (see https://numpy.org/doc/stable/reference/generated/numpy.logaddexp.html#numpy.logaddexp) where x1 and x2 are logpdf values.

@NAThompson
Copy link
Collaborator

A fast, numerically stable log-sum-exp seems like the natural place to start with this. I don't have much context for this problem; are there enough terms that it should it be parallelized?

@mborland

@mborland mborland linked a pull request Feb 15, 2022 that will close this issue
@mborland
Copy link
Member

Is the linked PR the first step of what you are looking for @HDembinski? Like you said it's not overly difficult to add logpdf support by distribution.

@NAThompson
Copy link
Collaborator

NAThompson commented Feb 15, 2022

@mborland : I think the hard part is getting the ULPs plots for all of these correct . . . but I think this is indeed a good start.

@HDembinski
Copy link
Contributor

Is the linked PR the first step of what you are looking for @HDembinski? Like you said it's not overly difficult to add logpdf support by distribution.

Yes, although the arcsine distribution is not the first that comes to mind. Ideal targets are the normal, poisson, exponential, beta, gamma, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants