Rubrik: Variablen/Strings · Algorithmen/Mathematik | VB-Versionen: VB2005, VB2008 | 11.12.09 |
Inverse der kumulativen Standard-Normalverteilung Die Umkehrfunktion zur kumulativen Standard-Normalverteilung liefert zu einer Wahrscheinlichkeit den entsprechenden z-Wert | ||
Autor: Manfred Bohn | Bewertung: | Views: 13.791 |
ohne Homepage | System: Win2k, WinXP, Win7, Win8, Win10, Win11 | kein Beispielprojekt |
Es ist die Umkehrfunktion zum VBARCHIV-Tipp "Integration der Standardnormalverteilung."
Die Funktion habe ich der Homepage von Peter J. Acklam entnommen und zur Verwendung in VB geringfügig angepasst. Auf der HomePage finden sich auch weiterführende Informationen zum Algorithmus:
http://home.online.no/%7Epjacklam/notes/invnorm/index.html
Laut dem Autor liegt der Fehler der Funktion bei weniger als 1.15 × 10−9.
Copyright-Vermerk des Autors:
"You can use the algorithm ... for whatever purpose you want, but please show common courtesy and give credit where credit is due."
''' <summary>Inverse der kumulativen Standardnormalverteilung</summary> ''' <param name="prob">Wahrscheinlichkeit (0-1)</param> ''' <returns>z-Wert für eine vorgegebene Wahrscheinlichkeit</returns> Public Function inverse_normal_cumulative_distribution(ByVal prob As Double) As Double ' Coefficients in rational approximations. Dim a(5), b(4), c(5), d(4) As Double a(0) = -39.696830286653757 : a(1) = 220.9460984245205 a(2) = -275.92851044696869 : a(3) = 138.357751867269 a(4) = -30.66479806614716 : a(5) = 2.5066282774592392 b(0) = -54.476098798224058 : b(1) = 161.58583685804089 b(2) = -155.69897985988661 : b(3) = 66.80131188771972 b(4) = -13.280681552885721 c(0) = -0.0077848940024302926 : c(1) = -0.32239645804113648 c(2) = -2.4007582771618381 : c(3) = -2.5497325393437338 c(4) = 4.3746641414649678 : c(5) = 2.9381639826987831 d(0) = 0.0077846957090414622 : d(1) = 0.32246712907003983 d(2) = 2.445134137142996 : d(3) = 3.7544086619074162 If prob < 0.0# Or prob > 1.0# Then Throw New System.ArgumentOutOfRangeException _ ("Mannomann: Die Wahrscheinlichkeit liegt im Bereich 0 bis 1") End If ' Cut Extremes If prob > 0.999986# Then Return 4.2 If prob < 0.000014# Then Return -4.2 ' Define break-points. Dim p_low As Double = 0.02425 Dim p_high As Double = 1 - p_low ' Helpers Dim q, r, x As Double If prob < 0.02425# Then ' Rational approximation for lower region. q = System.Math.Sqrt(-2 * System.Math.Log(prob)) x = (((((c(0) * q + c(1)) * q + c(2)) * q + c(3)) * q + c(4)) * q + c(5)) / _ ((((d(0) * q + d(1)) * q + d(2)) * q + d(3)) * q + 1) ElseIf prob <= 0.97575# Then ' Rational approximation for central region. q = prob - 0.5 : r = q * q x = (((((a(0) * r + a(1)) * r + a(2)) * r + a(3)) * r + a(4)) * r + a(5)) * q / _ (((((b(0) * r + b(1)) * r + b(2)) * r + b(3)) * r + b(4)) * r + 1) Else ' Rational approximation for upper region. q = System.Math.Sqrt(-2 * System.Math.Log(1 - prob)) x = -(((((c(0) * q + c(1)) * q + c(2)) * q + c(3)) * q + c(4)) * q + c(5)) / _ ((((d(0) * q + d(1)) * q + d(2)) * q + d(3)) * q + 1) End If ' get standard value related to prob Return System.Math.Round(x, 5) End Function