Home > marsbar > @mardo_2 > private > pr_spm_q.m

pr_spm_q

PURPOSE ^

returns an (n x n) autocorrelation matrix for an AR(p) process

SYNOPSIS ^

function [Q] = pr_spm_q(A,n)

DESCRIPTION ^

 returns an (n x n) autocorrelation matrix for an AR(p) process
 FORMAT [Q] = spm_Q(A,n)

 A  - vector pf p AR coeficients
 n  - size of Q
___________________________________________________________________________
 @(#)spm_Q.m    2.2 Karl Friston 03/03/03

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Q] = pr_spm_q(A,n)
0002 % returns an (n x n) autocorrelation matrix for an AR(p) process
0003 % FORMAT [Q] = spm_Q(A,n)
0004 %
0005 % A  - vector pf p AR coeficients
0006 % n  - size of Q
0007 %___________________________________________________________________________
0008 % @(#)spm_Q.m    2.2 Karl Friston 03/03/03
0009 
0010 % compute Q
0011 %---------------------------------------------------------------------------
0012 p    = length(A);
0013 A    = [1 -A(:)'];
0014 K    = inv(spdiags(ones(n,1)*A,-[0:p],n,n));
0015 K    = K.*(abs(K) > 1e-4);
0016 Q    = K*K';
0017 D    = spdiags(sqrt(1./diag(Q)),0,n,n);
0018 Q    = D*Q*D;
0019 Q    = Q.*(abs(Q) > 1e-4);

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019