Home > atmlab > covmat > covmat1d_markov.m

covmat1d_markov

PURPOSE ^

COVMAT1D_MARKOV Covariance matrix for a Markov process

SYNOPSIS ^

function [S,Sinv] = covmat1d_markov(n,sigma,dz,lc,cco)

DESCRIPTION ^

 COVMAT1D_MARKOV   Covariance matrix for a Markov process

    The function creates the covariance matrix and its inverse where the
    correlation can be described as a Markow process. For details, see
    "Inverse methods for atmospheric sounding" by C.D. Rodgers (Eq. 2.83,
    Sec. 10.3.2.2 and Exercise 10.2).

 FORMAT   [S,Sinv] = covmat1d_markov( n, sigma, dz, lc [,cco] )
        
 OUT   S       Covariance matrix, with size n x n. A sparse matrix.
       Sinv    The inverse of S. A sparse matrix.
 IN    n       Number of points
       sigma   Standard devation
       dz      Distance between grid points
       lc      Correlation length
 OPT   cco     Correlation cut-off. All values corresponding to a 
               correlation below this limit are set to 0 in S. This causes
               S*Sinv to deviate from the identity matrix, but can make S
               much more sparse.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

covmat1d_markov.m

SOURCE CODE ^

0001 % COVMAT1D_MARKOV   Covariance matrix for a Markov process
0002 %
0003 %    The function creates the covariance matrix and its inverse where the
0004 %    correlation can be described as a Markow process. For details, see
0005 %    "Inverse methods for atmospheric sounding" by C.D. Rodgers (Eq. 2.83,
0006 %    Sec. 10.3.2.2 and Exercise 10.2).
0007 %
0008 % FORMAT   [S,Sinv] = covmat1d_markov( n, sigma, dz, lc [,cco] )
0009 %
0010 % OUT   S       Covariance matrix, with size n x n. A sparse matrix.
0011 %       Sinv    The inverse of S. A sparse matrix.
0012 % IN    n       Number of points
0013 %       sigma   Standard devation
0014 %       dz      Distance between grid points
0015 %       lc      Correlation length
0016 % OPT   cco     Correlation cut-off. All values corresponding to a
0017 %               correlation below this limit are set to 0 in S. This causes
0018 %               S*Sinv to deviate from the identity matrix, but can make S
0019 %               much more sparse.
0020 
0021 % 2009-11-06   Created by Patrick Eriksson.
0022 
0023 
0024 function [S,Sinv] = covmat1d_markov(n,sigma,dz,lc,cco)
0025 
0026 if nargin < 5
0027   cco = 0;
0028 end
0029 
0030 
0031 % Constants
0032 %
0033 s2    = sigma * sigma;
0034 alpha = exp( -dz/lc );
0035 c1    = -alpha / ( 1 - alpha^2 ) / s2;
0036 c2    = 1/(1-alpha^2)/s2;
0037 
0038 % Seinv
0039 %
0040 row = [ 2:n 1:n 1:n-1 ];
0041 col = [ 1:n-1 1:n 2:n ];
0042 w   = [ repmat(c1,1,n-1) c2 repmat(c2*(1+alpha^2),1,n-2) c2 repmat(c1,1,n-1) ];
0043 %
0044 Sinv = sparse( row, col, w, n, n );
0045 
0046 
0047 S = covmat1d_from_cfun( 0:dz:dz*(n-1)*dz, sigma, 'exp', lc, cco );
0048

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005