Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This is for a project which I've been trying to find some information for Covariance matrix and correlation matrix.

I understand that for a $n \times n$ matrix $A, AA^T$ will give me the covariance matrix.

Is there any relationship between the covariance and correlation matrix?

Sorry maybe I wasn't clear.

I wanted to use Cholesky decomposition to generate correlated variables from random variables. I do know how to do it using matlab. And I understand how it works for 2 variables. But when I scale up the matrix to $n \times n$ instead of $2 \times 2$, I am not sure how it will work out.

would appreciate if someone could provide more hint on the mathematics.

Thanks!

share|improve this question

5 Answers 5

Suppose you have a random vector $\mathbf{g}$, then the covariance matrix of $\mathbf{g}$ is defined as $$\mathbf{K}=\mathbf{E}\{(\mathbf{g}-\bar{\mathbf{g}})(\mathbf{g}-\bar{\mathbf{g}})^{\dagger}\}$$ where $\mathbf{E}$ denotes expectation, $\bar{\mathbf{g}}$ denotes the mean of $\mathbf{g}$, $\dagger$ means transpose for real random vector, and conjugate transpose for complex random vector.

The correlation matrix is $$\mathbf{R}=\mathbf{E}\{\mathbf{g}\mathbf{g}^{\dagger}\}$$

So we have $$\mathbf{K}=\mathbf{R}-\bar{\mathbf{g}}\bar{\mathbf{g}}^{\dagger}$$

For zero-mean random vectors $\mathbf{K}=\mathbf{R}$.

EDIT: for another definition where the correlation matrix is the normalized covariance matrix, the relation is $$\mathbf{R}_{ij}=\frac{\mathbf{K}_{ij}}{\sigma_i \sigma_j}$$ where $\sigma_i, \sigma_j$ are the standard deviation of $\mathbf{g}_i$ and $\mathbf{g}_j$, respectively.

share|improve this answer
    
"correlation matrix" can mean that, but a more usual meaning is the normalized covariance matrix (i.e. correlation factors) –  leonbloy Aug 26 '12 at 4:02

From a matrix algebra point of view the answer is fairly simple. Assume your covariance matrix is $\Sigma$ and let

$$ D =\sqrt{ \text{diag}\left( {\Sigma} \right)} $$

then the correlation matrix is given by $$ \varrho = D^{-1}\Sigma D^{-1} $$

Edit: fixed to include square root

share|improve this answer
    
missing a square root, $D=\sqrt{\text{diag}(\Sigma)}$ –  karakfa Mar 18 '13 at 12:47
    
Thanks, I fixed that now. –  Brian B Mar 18 '13 at 12:58
    
Strictly speaking, $\text{diag}(\Sigma)$ is a square matrix, isn't it? (Otherwise its inverse is not defined). But then, there exists nothing like a square root of a matrix. Of course, I see that you have to take the sqrt of each element and put them back in a diagonal matrix. But has someone a more pure notation using matrices? –  hplieninger Sep 24 '13 at 8:24

Yes there is a one-to-one relation between two matrices. Please check:

http://www.riskglossary.com/link/correlation.htm

share|improve this answer

$$ D = \operatorname{diag}(\sqrt{\text{covariance matrix}}). $$ You have to put the square root!

share|improve this answer

Matlab has a function cov2corr to extract the correlation matrix from covariance matrix. If you're already using Matlab, no need to reinvent the wheel. The implementation of the function is similar to chaohuang's answer above (with some error checking).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.