返回列表 上一主題 發帖

[轉貼] 常態分佈函數

[轉貼] 常態分佈函數

Option Explicit

Sub Main()
    Dim x, F
    For x = 1 To 5
        Norm x, F   '調用計算常態分佈函數的副程式
        Debug.Print "常態偏離點 x =", x, "下側概率 F =", F
    Next x
    For x = -1 To -5 Step -1
        Norm x, F   '調用計算常態分佈函數的副程式
        Debug.Print "常態偏離點 x =", x, "下側概率 F =", F
    Next x
End Sub


'計算常態分佈函數
'x:常態偏離點
'F:下側概率
Public Sub Norm(x, F)
    Dim y As Double, ER As Double, Q As Double
    Dim A
    Const a1 As Double = 0.0705230784
    Const a2 As Double = 0.0422820123
    Const a3 As Double = 0.0092705272
    Const a4 As Double = 0.0001520143
    Const a5 As Double = 0.0002765672
    Const a6 As Double = 0.0000430638
    y = 0.707106781187 * Abs(x)
    A = a4 + y * (a5 + y * a6)
    A = a3 + y * A
    A = a2 + y * A
    A = a1 + y * A
    ER = 1 - (1 + y * A) ^ (-16)
    Q = 0.5 * ER
    If x < 0 Then F = 0.5 - Q Else F = 0.5 + Q
End Sub
程式人員

        靜思自在 : 要批評別人時,先想想自己是否完美無缺。
返回列表 上一主題