[SciPy-user] recursive least squares
John Hassler
hasslerjc at comcast.net
Mon Oct 1 19:29:33 EDT 2007
The basic function is very easy to write. (It can get much more
complex, of course.) Here is a Matlab version from when I taught a
course in self-tuning control a dozen years ago. If I can find a little
time this evening, I'll translate it into Python, although it's probably
obvious.
john
function [th,p] = rolsf(x,y,p,th,lam)
% function [th,p] = rolsf(x,y,p,th,lam)
% Recursive ordinary least squares for single output case,
% including the forgetting factor, lambda.
% Enter with x = input, y = output, p = covariance, th = estimate,
lam = forgetting factor
%
a=p*x;
g=1/(x'*a+lam);
k=g*a;
e=y-x'*th;
th=th+k*e;
p=(p-g*a*a')/lam;
Alan G Isaac wrote:
> Recursive least squares
> http://en.wikipedia.org/wiki/Recursive_least_squares
> is often used as a parameter instability diagnostic
> in time series applications.
>
> Is it available in SciPy?
>
> Thank you,
> Alan Isaac
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
>
More information about the SciPy-User
mailing list