Home > . > recursive_moments.m

recursive_moments

PURPOSE ^

stephane.adjemian@cepremap.cnrs.fr [02-03-2005]

SYNOPSIS ^

function [mu,sigma] = recursive_moments(m0,s0,data,offset)

DESCRIPTION ^

 stephane.adjemian@cepremap.cnrs.fr [02-03-2005]

 m0    :: the initial mean, assumed to be a n*1 vector.
 s0    :: the initial variance, assumed to be a n*n matrix.
 data  :: T*n matrix.  

 mu    :: the sample mean, a n*1 vector.
 sigma :: the sample covariance matrix, a n*n matrix.

 --> TODO: dll

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mu,sigma] = recursive_moments(m0,s0,data,offset)
0002 % stephane.adjemian@cepremap.cnrs.fr [02-03-2005]
0003 %
0004 % m0    :: the initial mean, assumed to be a n*1 vector.
0005 % s0    :: the initial variance, assumed to be a n*n matrix.
0006 % data  :: T*n matrix.
0007 %
0008 % mu    :: the sample mean, a n*1 vector.
0009 % sigma :: the sample covariance matrix, a n*n matrix.
0010 %
0011 % --> TODO: dll
0012 T = size(data,1);
0013 n = size(data,2);
0014 
0015 for t = 1:T
0016   tt = t+offset;
0017   m1 = m0 + (1/tt)*(data(t,:)'-m0);
0018   s1 = s0 + (1/tt)*(data(t,:)'*data(t,:)-m1*m1'-s0) + ((tt-1)/tt)*(m0*m0'-m1*m1');
0019   m0 = m1;
0020   s0 = s1;
0021 end
0022 
0023 mu = m1;
0024 sigma = s1;
0025 
0026 
0027   
0028

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003