[Numpy-discussion] Why do weights in np.polyfit have to be 1D?
Charles R Harris
charlesr.harris at gmail.com
Fri Jan 10 12:02:01 EST 2014
On Fri, Jan 10, 2014 at 9:03 AM, Andreas Hilboll <lists at hilboll.de> wrote:
> Hi,
>
> in using np.polyfit (in version 1.7.1), I ran accross
>
> TypeError: expected a 1-d array for weights
>
> when trying to fit k polynomials at once (x.shape = (4, ), y.shape = (4,
> 136), w.shape = (4, 136)). Is there any specific reason why this is not
> supported?
>
The weights are applied to the rows of the design matrix, so if you have
multiple weight vectors you essentially need to iterate the fit over them.
Said differently, for each weight vector there is a generalized inverse and
if there is a different weight vector for each column of the rhs, then
there is a different generalized inverse for each column. You can't just
multiply the rhs from the left by *the* inverse. The problem doesn't
vectorize.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140110/10791883/attachment.html>
More information about the NumPy-Discussion
mailing list