[Master Index]
[Index for export/brede]
brede_mat_cov
(export/brede/brede_mat_cov.m)
Function Synopsis
C = brede_mat_cov(X, Y, varargin)
Help text
brede_mat_cov - Covariance matrix
C = brede_mat_cov(X, Y)
Input: X 'Mat' structure or matrix
Y 'Mat' structure or matrix
Propery Normalize [ {n-1} | {n} ] Normalization
Output: C 'Mat' struture with covariance
Covariance between two matrices:
C = Xc'*Yc / (N-1)
where Xc and Yc are the centered matrices of X and Y.
Missing values (indicated with NaN) are ignored by default
which might result in a negative definite matrix.
Example:
% The covariance of gaussian distributed variables
n=1000; m=100;
C = brede_mat_cov(randn(n,m), randn(n,m))
figure, step=0.1; x = -4:step:4;
hist(C.matrix(:)*sqrt(n), x)
line(x, brede_pdf_gauss(x)*m^2*step)
% With missing values
A = randn(n,m);
A(1:n/2,1:m/2) = NaN;
C = brede_mat_cov(A, randn(n,m))
figure
subplot(2,1,1)
c = C.matrix(1:m/2,:); hist(c(:)*sqrt(n/2), x)
line(x, brede_pdf_gauss(x)*(m/2)*m*step)
subplot(2,1,2)
c = C.matrix(m/2+1:end,:); hist(c(:)*sqrt(n), x)
line(x, brede_pdf_gauss(x)*(m/2)*m*step)
See also BREDE, BREDE_MAT, BREDE_MAT_CORRCOEF,
BREDE_MAT_PARTCORRCOEF, BREDE_MAT_MEAN.
$Id: brede_mat_cov.m,v 1.6 2008/03/12 14:17:01 fn Exp $
Cross-Reference Information
This function calls
Produced by mat2html on Fri Jun 20 17:43:05 2008
Cross-Directory links are: OFF