import numpy as np
#随机矩阵 A
A=np.random.randint(1,25,[3,5])
u,sigma,vt = np.linalg.svd(A)
print(A@ vt[-1])
def fitline(points):
#ax+by+c=0
#solve Ax =0:
#ax0+by0+c=0
#ax1+by1+c=0
#ax2+by2+c=0
#...
points = np.concatenate((points, np.ones(len(points)).reshape(-1, 1)),axis=1)
u,sigma,vt = np.linalg.svd(points)
v= np.transpose(vt)
return vt[-1]
x= np.arange(0,100)
x = x.reshape(-1,1)
y =2*x +1
points=np.column_stack((x,y))
print(fitline(points))
[ 0.81649658 -0.40824829 0.40824829]