Private Sub Command1_Click()
Dim ls As Single
Dim cs As Single
Dim us As Single
Dim l1 As Single
Dim c1 As Single
Dim u1 As Single
Dim l2 As Single
Dim c2 As Single
Dim u2 As Single
Dim th As Single
Dim h As Single
Dim lp As Single
Dim t1 As Single
Dim t2 As Single
Dim e As Single
Dim b As Single
Dim u(-10 To 10) As Single
Dim s As Single
For s = -10 To 10
b = 0.01 * s
e = 10 ^ (-5)
h = 0.1
th = 1
ls = (b + 0.5) / th
cs = th * ls - b
us = Log(cs) + Log(1 - ls)
t2 = 0
Do Until t2 > 10
t1 = 0
Do Until t1 > 100
l1 = ls + h
If l1 > 0.99 Then l1 = ls
c1 = th * l1 - b
u1 = Log(c1) + Log(1 - l1)
l2 = ls - h
If l2 < 0.01 Then l2 = ls
c2 = th * l2 - b
If c2 < 0.01 Then l2 = ls
c2 = th * l2 - b
u2 = Log(c2) + Log(1 - l2)
If u1 > us Then ls = l1
If u1 > us Then us = u1
If u2 > us Then ls = l2
If u2 > us Then us = u2
If (lp - ls) ^ 2 < e Then t1 = 1000
lp = ls
t1 = t1 + 1
Loop
h = h / 2
t2 = t2 + 1
Loop
u(s) = us
Next
For s = -10 To 10
Debug.Print s, u(s)
Next
End Sub
最終更新:2009年08月03日 18:10