Home > atmlab > randomize > randmvar_add_normal.m

randmvar_add_normal

PURPOSE ^

RANDMVAR_ADD_NORMAL Random multivariate data with normal distribution

SYNOPSIS ^

function [P,C] = randmvar_add_normal(P,C,xm,si,Cm)

DESCRIPTION ^

 RANDMVAR_ADD_NORMAL   Random multivariate data with normal distribution

   Prepares input to *randmvar* to include data with normal (Gaussian) 
   distribution. The statistical properties are set by mean value, standard
   deviation and the covariance matrix for the data variables to be included.

   Zero correlation to already included variables is assumed.

 FORMAT   [P,C] = randmvar_add_normal( P, C, xm, si, Cm )
        
 OUT   P       Description of probability distribution function. See 
               *randmvar* for format description.
       C       Correlation matrix. 
 IN    P       Description of probability distribution function for already 
               added variables.
       C       Correlation matrix for already added variables. 
       xm      Mean vector.
       si      Vector of standard deviations.
       C       Correlation matrix for variables to be added.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

randmvar_add_normal.m

SOURCE CODE ^

0001 % RANDMVAR_ADD_NORMAL   Random multivariate data with normal distribution
0002 %
0003 %   Prepares input to *randmvar* to include data with normal (Gaussian)
0004 %   distribution. The statistical properties are set by mean value, standard
0005 %   deviation and the covariance matrix for the data variables to be included.
0006 %
0007 %   Zero correlation to already included variables is assumed.
0008 %
0009 % FORMAT   [P,C] = randmvar_add_normal( P, C, xm, si, Cm )
0010 %
0011 % OUT   P       Description of probability distribution function. See
0012 %               *randmvar* for format description.
0013 %       C       Correlation matrix.
0014 % IN    P       Description of probability distribution function for already
0015 %               added variables.
0016 %       C       Correlation matrix for already added variables.
0017 %       xm      Mean vector.
0018 %       si      Vector of standard deviations.
0019 %       C       Correlation matrix for variables to be added.
0020 
0021 % 2005-05-21   Created by Patrick Eriksson.
0022 
0023 
0024 function [P,C] = randmvar_add_normal(P,C,xm,si,Cm)
0025 
0026 
0027 %= Check input
0028 %
0029 rqre_nargin( 5, nargin );
0030 %
0031 if ndims(C) > 2  |  size(C,1) ~= size(C,1) 
0032   error('Input argument *C* must be a square matrix.');
0033 end
0034 %
0035 if length(P) ~= size(C,1)
0036   error('Mismatch in size between *P* and *C*.');
0037 end
0038 %
0039 if ~isvector(xm)
0040   error('Input argument *xm* must be a vector.');
0041 end
0042 %
0043 if ~isvector(si)  |  length(xm) ~= length(si)
0044   error('Input argument *si* must be a vector with same length as *xm*.');
0045 end
0046 %
0047 if any( si <= 0 )
0048   error('All values of *si* must be >0.');
0049 end
0050 %
0051 if ndims(Cm) > 2  |  size(Cm,1) ~= size(Cm,1) 
0052   error('Input argument *Cm* must be a square matrix.');
0053 end
0054 %
0055 if length(xm) ~= size(Cm,1) 
0056   error('Mismatch in size between *xm* and *Cm*.');
0057 end
0058 
0059 
0060 np = length( P );
0061 nx = length( xm );
0062 
0063 P{np+nx} = [];
0064 
0065 for i = 1 : nx
0066   %
0067   P{np+i}.cdf = [ xm(i) si(i) ];
0068   %
0069 end
0070 
0071 C = covmat_append( C, Cm );
0072 
0073

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