[SciPy-User] polyval, polyfit on 2D array

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Sep 3 08:58:29 EDT 2009


On Thu, Sep 3, 2009 at 3:40 AM, <markus.proeller at ifm.com> wrote:
>
> Hello everyone,
>
> I have a two dimensional array with a shape of (600,800) and want to apply
> polyval and polyfit on each of the 600 lines.
> Is there an elegant way to avoid a for loop over axis 0?
> So for one line my code would be this:
>
>>>> x=arange(800)
>>>> p = polyfit(x, y[0,:])
>>>> y_new = polyval(p, x)
>
> Thanks for help,
>
> Markus

if you want just a linear fit then there was the discussion and recipe
some time ago on numpy-discussion
"polyfit on multiple data points" and "performance issue (again)"

Josef



More information about the SciPy-User mailing list