标准正态分布函数曲线怎么画不出来?
标准正态分布函数就是其概率密度函数的积分
因此我对每个函数值都进行求和,不过结果不是我想要的,在小于0的部分,函数值为0 大于0 的部分函数值为一
下面是我的代码,用一个command跟一个picture控件,那位大哥帮我看看吧
Dim o As Integer
Private Sub Command1_Click()
Picture1.Scale (-1000, 1)-(1000, -1)
For o = -1000 To 1000
Picture1.PSet (o, Ztfbhs(o))
Next o
End Sub
Function Ztfbhs(o) As Double
Dim q, h2, pi, s, y2, x2, z2(1 To 1000) As Double
' a2 = 0
'b2 = 1
q = 0.0001
h2 = 0.1
pi = 3.1415926
s = 0
x2 = 0
'If (o - a2) / b2 < 0 Then
If o < 0 Then
'Do While x2-q > (o - a2) / b2
Do While x2 - q > o
s = s + (Exp(-(x2 ^ 2 / 2)) + Exp(-((x2 - h2) ^ 2 / 2))) * h2 / (2 * Sqr(2 * pi))
x2 = x2 - h2
Loop
Ztfbhs = 0.5 - s
Else
'Do While x2+q < (o - a2) / b2
Do While x2 + q < o
s = s + (Exp(-(x2 ^ 2 / 2)) + Exp(-((x2 + h2) ^ 2 / 2))) * h2 / (2 * Sqr(2 * pi))
x2 = x2 + h2
Loop
Ztfbhs = 0.5 + s
End If
End Function
[解决办法]
算法的问题很头疼阿,帮顶