[Top][All Lists]

[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.



Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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