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

stable log cdfs for normal #3150

Open
bob-carpenter opened this issue Feb 21, 2025 · 2 comments
Open

stable log cdfs for normal #3150

bob-carpenter opened this issue Feb 21, 2025 · 2 comments

Comments

@bob-carpenter
Copy link
Member

Stan's log cdfs just take the log of the linear cdf, so they're prone to underflow to -infinity after the cdc underflows to 0 or rounds to 1.

The R implementation of log cdfs is more stable, e.g.,

> pnorm(-50, log=TRUE)
[1] -1254.831

We should be able to borrow an implementation from R or from SciPy.

@SteveBronder
Copy link
Collaborator

Here is the source code for pnorm
/~https://github.com/wch/r-source/blob/trunk/src/nmath/pnorm.c#L90

@andrjohns
Copy link
Collaborator

The standard-normal lcdf already uses that algorithm I believe

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

No branches or pull requests

3 participants