math icon indicating copy to clipboard operation
math copied to clipboard

Update Normal quantile function with new approximations

Open andrjohns opened this issue 2 years ago • 3 comments

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

andrjohns avatar Oct 16 '23 04:10 andrjohns

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.

spinkney avatar Oct 16 '23 14:10 spinkney

@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 avatar Oct 19 '23 12:10 andrjohns

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

andrjohns avatar Oct 19 '23 12:10 andrjohns