VB常用数值算法集
内含有解线性代数方程组
源代码在线查看: d9r1.txt
Private Sub Command1_Click()
'PROGRAM D9R1
'Driver for routine FIT
NPT = 100
SPREAD = 0.5
Dim X(100), Y(100), SIG(100)
IDUM& = -117
For I = 1 To NPT
X(I) = 0.1 * I
Y(I) = -2# * X(I) + 1# + SPREAD * GASDEV(IDUM&)
SIG(I) = SPREAD
Next
For MWT = 0 To 1
Call FIT(X(), Y(), NPT, SIG(), MWT, A, B, SIGA, SIGB, CHI2, Q)
If MWT = 0 Then
Print
Print Tab(5); "Ignoring standard deviation"
Print
Else
Print
Print Tab(5); "Including standard deviation"
Print
End If
Print Tab(5); "A = "; Format$(A, "##.#####0"),
Print "Uncertainty: "; Format$(SIGA, "##.#####0")
Print
Print Tab(5); "B = "; Format$(B, "##.#####0"),
Print "Uncertainty: "; Format$(SIGB, "##.#####0")
Print
Print Tab(5); "Chi-squared: "; Format$(CHI2, "##.#####0")
Print
Print Tab(5); "Goodness-of-fit: "; Format$(Q, "##.000000")
Next MWT
End Sub