题目
解
import numpy as np x_h = np.array([178,179,170,179,165,169,177,167,172,167]) f_h = np.array([185,187,176,187,168,173,182,177,180,170]) x_bar = np.average(x_h) f_bar = np.average(f_h) sum1 = np.dot(x_h,f_h.transpose()) sum2 = np.dot(x_h,x_h.transpose()) w = (sum1 - 10*x_bar*f_bar)/(sum2-10*x_bar*x_bar) b = f_bar - w * x_bar print(w,b)