import numpy as np
import matplotlib.pyplot as plt
t1 = np.random.random()
t2 = np.random.random()
t3 = np.random.random()
t0 = np.array([t2, t3])
a = 0.0000001
t = np.array([400, 330, 369, 232, 540])
x = np.array([[2104, 3], [1600, 3], [2400, 3], [1416, 2], [3000, 4]])
i = 0
eps = 1e-4
e0 = 99
e1 = 99
e2 = 99
while e0 >= eps or e1 >= eps or e2 >= eps:
i +=1
e0 = (np.sum((x[i, 0:1] * t0[i])) + t1 * 1 - t[i])
e1 = e0 * x[i, 0]
e2 = e0 * x[i, 1]
t1 = t1 - a * e0
t2 = t2 - a * e1
t3 = t3 - a * e2
print(t1, t2, t3)
2021-09-03作业
最新推荐文章于 2024-09-09 00:00:00 发布