[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: detrend

**From**: |
Teemu Ikonen |

**Subject**: |
Re: detrend |

**Date**: |
Wed, 18 Oct 2000 23:11:36 +0300 (EET DST) |

On Wed, 18 Oct 2000, flatmax wrote:
>* Can any one technically define what is happening in the 'detrend'*
>* algorithm ?*
>* *
>* function y = detrend (x, p)*
>* r = rows (x);*
>* b = ((1 : r)' * ones (1, p + 1)) .^ (ones (r, 1) * (0 : p));*
>* y = x - b * (b Ü x);*
The second row creates a polynomial fitting matrix (Vandermonde
matrix) b. b could also be written as
[(1:r)'.^0, (1:r)'.^1, ..., (1:r)'.^p]
In the third row (b Ü x) is a solution (in least squares sense) to
b*a = x,
where vector a has length p+1. b*a (= b * (b Ü x)) is then simply a vector
of values of the best fit polynomial of order p to data x. This is then
subtracted from the original data.
HTH,
Teemu
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------

**detrend**, *flatmax*, `2000/10/18`
**Re: detrend**, *Tristan Quaife*, `2000/10/18`
**Re: detrend**,
*Teemu Ikonen* **<=**