Post Reply 
Best (and Newest?) Approximations for Popular Inverse Distributions
03-18-2019, 02:45 PM (This post was last modified: 03-18-2019 02:59 PM by Pekis.)
Post: #11
RE: Best (and Newest?) Approximations for Popular Inverse Distributions
Hello Namir,

I found this not too heavy erfinv function by Mike Giles with these notes:

... Regarding accuracy, the maximum error of the new single precision approximation,
compared to the existing double precision version, is around
7×10−7 ...


I then transformed it in VBA using invphi(p) = sqrt(2) * erfinv(2*p-1)

Public Function invphi(prob As Double)
Dim x As Double, t As Double
Dim w As Double, p As Double

t = 2 * prob - 1
x = Abs(t)
w = -Log((1 - x) * (1 + x))
If (w < 5) Then
w = w - 2.5
p = 2.81022636E-08
p = 0.000000343273939 + p * w
p = -0.0000035233877 + p * w
p = -0.00000439150654 + p * w
p = 0.00021858087 + p * w
p = -0.00125372503 + p * w
p = -0.00417768164 + p * w
p = 0.246640727 + p * w
p = 1.50140941 + p * w
Else
w = Sqr(w) - 3
p = -0.000200214257
p = 0.000100950558 + p * w
p = 0.00134934322 + p * w
p = -0.00367342844 + p * w
p = 0.00573950773 + p * w
p = -0.0076224613 + p * w
p = 0.00943887047 + p * w
p = 1.00167406 + p * w
p = 2.83297682 + p * w
End If
invphi = Sgn(t) * p * x * Sqr(2)
End Function
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Best (and Newest?) Approximations for Popular Inverse Distributions - Pekis - 03-18-2019 02:45 PM



User(s) browsing this thread: 1 Guest(s)