[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving polynomial fit

From: macy
Subject: Re: Moving polynomial fit
Date: Sat, 5 Sep 2009 08:38:38 -0700 (PDT)
User-agent: SquirrelMail/1.4.13

I had to do something like this for 2 minutes of streaming data once.  The
FOR loop took 20 minutes+ and the array process took 12 seconds!

It went something like this:

Multiply the original vector in such a way as to make a 'shifted' array.

Where each line of the array is your original vector, but shifted slightly.

Then, apply to the array in a single stomp and you should be there

I had to expand the memory octave used, else kept crashing my system when
the data files were up around 20MB


> I would like to write a script/function for use on a time series that will
> least squares fit a polynomial of a given degree to a moving window across
> the time series in the same way as a moving average computes an average of
> a
> moving window, the output of the script/function being a vector of the
> extreme right hand edge/last values of the fitted polynomial over the
> moving
> window. I have tried using the Savitsky-Golay filters from the Signals
> package but they are not suitable for my purposes as the end conditions
> mean
> that the values of the fitted polynomial at the right hand edges of the
> moving window are different from the values calculated when the data are
> no
> longer at the right hand edge. What in-built Octave functions should I
> consider using to achieve the above i.e. polyfit or some other
> function(s)?
> Also, as loops can be quite slow, is there a more efficient way of coding
> the above rather than having to resort to a for loop?
> --
> View this message in context:
> Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]