作业帮 > 综合 > 作业

VB最小二乘法拟合曲线

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 23:01:24
VB最小二乘法拟合曲线

将此数据用最小二乘法拟合曲线,曲线公式形式如下:

通过拟合求出c和b,计算时可以用对数或者改变公式形式,只要能求出c和b就行,

麻烦给出编程过程
VB最小二乘法拟合曲线
N = UBound(Cyc) - LBound(Cyc) + 1
ReDim U(4, N)
ReDim V(4, N)
For I = 0 To N - 2
U(0, I) = Log(D(I))
U(1, I) = Log(A(I) * E(I) / 2)
U(2, I) = U(0, I) * U(1, I)
U(3, I) = U(0, I) ^ 2
U(0, 0) = U(0, 0) + U(0, I)
U(1, 0) = U(1, 0) + U(1, I)
U(2, 0) = U(2, 0) + U(2, I)
U(3, 0) = U(3, 0) + U(3, I)

V(0, I) = Log(D(I))
V(1, I) = Log(-1 * B(I) / 2)
V(2, I) = V(0, I) * V(1, I)
V(3, I) = V(0, I) ^ 2
V(0, 0) = V(0, 0) + V(0, I)
V(1, 0) = V(1, 0) + V(1, I)
V(2, 0) = V(2, 0) + V(2, I)
V(3, 0) = V(3, 0) + V(3, I)
Next I
U(0, 0) = U(0, 0) / N
U(1, 0) = U(1, 0) / N
cal_b = (U(2, 0) - N * U(0, 0) * U(1, 0)) / (U(3, 0) - N * U(0, 0) ^ 2)
cal_C = U(1, 0) - cal_b * U(0, 0)
cal_C = Exp(cal_C)
V(0, 0) = V(0, 0) / N
V(1, 0) = V(1, 0) / N
cal_m = (V(2, 0) - N * V(0, 0) * V(1, 0)) / (V(3, 0) - N * V(0, 0) ^ 2)
cal_d = V(1, 0) - cal_m * V(0, 0)
cal_d = -1 * Exp(cal_d)