[SciPy-user] recursive least squares

John Hassler hasslerjc@comcast....
Mon Oct 1 18:29:33 CDT 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@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
>   


More information about the SciPy-user mailing list