# Difference between revisions of "Seg18. The Correlation Matrix"

## Skilled problem

### problem 1

Random points i are chosen uniformly on a circle of radius 1, and their $(x_i,y_i)$ coordinates in the plane are recorded. What is the 2x2 covariance matrix of the random variables $X$ and $Y$? (Hint: Transform probabilities from $\theta$ to $x$. Second hint: Is there a symmetry argument that some components must be zero, or must be equal?)

The matrix would be $\begin{bmatrix}  Cov(X,X) & Cov(X,Y) \\ Cov(Y,X) & Cov(Y,Y) \\ \end{bmatrix}$


Since the sample space is symmetric and the sampling is uniform, it's easy to see the mean for x,y are both 0. And the covarience of X and X is it's variance. So the matrix is actually:

$\begin{bmatrix}  <x^2> & <xy> \\ <yx> & <y^2> \\ \end{bmatrix}$


And since x,y is on the circle, thus $x = cos\theta, y = sin\theta$

Thus, the matrix would be $\begin{bmatrix}  \pi & 0 \\ 0 & \pi \\ \end{bmatrix}$


### problem 2

Points are generated in 3 dimensions by this prescription: Choose λ uniformly random in (0,1). Then a point's (x,y,z) coordinates are (αλ,βλ,γλ). What is the covariance matrix of the random variables (X,Y,Z) in terms of α,β, and γ? What is the linear correlation matrix of the same random variables?

The covariance matrix C will be (Let $X_1 = X, X_2 = Y, X_3 = Z$):

The mean for three variables are ($\frac{\alpha}2, \frac{\beta}2, \frac{\gamma}2$)

The diagonal value will be the variance of each variable

$Var(X) = \int_0^1 (\alpha \lambda - \frac{\alpha}2 )^2 \cdot 1 d \lambda = \frac{\alpha^2}{12}$

For values that are not diagaonal,

$Cov(X,Y) = <(X - \bar{X}) (Y - \bar{Y})> = \alpha\beta \int_0^1 (\lambda - \frac12)^2 d\lambda = \frac{\alpha\beta}{12}$

So the covariance matrix is

$\begin{bmatrix} \frac{\alpha^2}{12} & \frac{\alpha\beta}{12} & \frac{\alpha\gamma}{12} \\ \frac{\alpha\beta}{12} & \frac{\beta^2}{12} & \frac{\beta\gamma}{12} \\ \frac{\alpha\gamma}{12} & \frac{\beta\gamma}{12} & \frac{\gamma^2}{12} \\ \end{bmatrix}$

since $r = \frac{C_{ij}}{\sqrt{C_{ii} \cdot C_{jj}}}$

The linear matrix will be $\begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \\ \end{bmatrix}$

## Thought problem

### problem 1

Suppose you want to get a feel for what a linear correlation r = 0.3 (say) looks like. How would you generate a bunch of points in the plane with this value of r? Try it. Then try for different values of r. As r increases from zero, what is the smallest value where you would subjectively say "if I know one of the variables, I pretty much know the value of the other"?

### problem 2

Suppose that points in the (x,y) plane fall roughly on a 45-degree line between the points (0,0) and (10,10), but in a band of about width w (in these same units). What, roughly, is the linear correlation coefficient r?

The point (x,y) satisfy the relation that:

$\begin{cases} | x - y | \le \frac{\sqrt{2}w}2 \\ x, y \isin [0,10] \end{cases}$