This commit is contained in:
lwj
2025-06-13 23:08:32 +08:00
parent e5729d884f
commit 3fc9330dd6
3 changed files with 28 additions and 17 deletions

13
89-2.py
View File

@@ -1,9 +1,5 @@
import math
x = [1,2,4,8,16,32,64]
y = [4.22,4.02,3.85,3.59,3.44,3.02,2.59]
# 列主元高斯消元法
def SovleRowMain(A,b):
ks = 0.00000001
@@ -63,8 +59,15 @@ def LeastSquares(list_x,list_y,n):
for j in range(n+1):
tmp.append(x_n[i+j])
A.append(tmp)
return SovleRowMain(A,b)
print("A:", A)
print("b:", b)
result = SovleRowMain(A, b)
print("result:", result)
return result
#把x和y的值改为实际数据#######################
x = [1,2,4,8,16,32,64]
y = [4.22,4.02,3.85,3.59,3.44,3.02,2.59]
if __name__ == "__main__":
# 取对数 ln(W) = ln(C)+lamda*ln(t)
ln_W = [math.log(i) for i in y]