超定
代码
x = [2,3,4]
X = [1,1,1;x]
W = [10;9]
Y = W'*X
Y_observed = Y+10*(rand([1,3])-0.5)
scatter(x, Y_observed)
hold on
plot(x, Y)
W_estimated = X'\Y'
Y_estimated = W_estimated'*X
plot(x, Y_estimated)
效果
欠定
W_estimated1 = null(X') # 获得矩阵X'零空间的标准正交基
W_estimated2 = X'\Y' # 获得非齐次线性方程组特解
W_estimated = W_estimated1*K+W_estimated2