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

Update Normal quantile function with new approximations #2964

Open
andrjohns opened this issue Oct 16, 2023 · 3 comments
Open

Update Normal quantile function with new approximations #2964

andrjohns opened this issue Oct 16, 2023 · 3 comments

Comments

@andrjohns
Copy link
Collaborator

Description

The R project recently published a vignette covering various approximations for the quantiles of the normal distribution, including for log inputs: https://CRAN.R-project.org/package=DPQ/vignettes/qnorm-asymp.pdf

@spinkney
Copy link
Collaborator

I believe the regular version is nearly the same as what is in today. The log version in this paper should be much faster than what is in Stan and it has a larger range of values.

@andrjohns
Copy link
Collaborator Author

@spinkney I'm working on translating the code across now, and it looks like there are improvements for the regular version as well (hooray!).

This test which used to underflow to -Inf now correctly evaluates to -37.6725.

Additionally, it also detected that some of the exact values are actually a little bit off. For example the exact value for inv_Phi(0.999999999) here is actually wrong: https://www.wolframalpha.com/input?i=NumberForm%5BInverseCDF%5BNormalDistribution%5B0%2C1%5D%2C0.999999999%5D%2C16%5D

Cool stuff!

@andrjohns
Copy link
Collaborator Author

Additionally, it also detected that some of the exact values are actually a little bit off

Ahhh I take it back, it's a floating-point precision issue. Using exact inputs matches the test vals: https://www.wolframalpha.com/input?i=N%5BInverseCDF%5BNormalDistribution%5B0%2C1%5D%2C999999999%2F1000000000%5D%2C16%5D

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

No branches or pull requests

2 participants