Understanding scipy's least square function with IRLS

前端 未结 2 696
独厮守ぢ
独厮守ぢ 2020-12-29 11:13

I\'m having a bit of trouble understanding how this function works.

a, b = scipy.linalg.lstsq(X, w*signal)[0]

I know that signal is the arr

2条回答
  •  情书的邮戳
    2020-12-29 11:31

    Create a diagonal matrix W from the elementwise square-roots of w. Then I think you just want:

    scipy.linalg.lstsq(np.dot(W, X), np.dot(W*signal))
    

    Following http://en.wikipedia.org/wiki/Linear_least_squares_(mathematics)#Weighted_linear_least_squares

提交回复
热议问题