[Numpy-discussion] Polyfit

Anne Archibald peridot.faceted at gmail.com
Mon Jun 16 21:33:11 EDT 2008


2008/6/16 Chandler Latour <deathicrow at gmail.com>:
> I believe I'm bound to python.
> In terms of forcing the regression through the origin, the purpose is partly
> for visualization but it also should fit the data.  It would not make sense
> to model the data with an initial value other than 0.

Polyfit is just a thin wrapper around numpy.linalg.lstsq. You can do
something like:
A = np.power.outer(xs,np.arange(1,n))
outputs = np.linalg.lstsq(A,ys)

Anne



More information about the NumPy-Discussion mailing list