# Covariance Matrix Polar to Cartesian

Let $$R$$ and $$\Theta$$ be zero mean independent Gaussian random variables with variances $$\sigma_R^2$$ and $$\sigma_\Theta^2$$ respectively. Hence their covariance matrix would be diagonal give by $$C_{R,\Theta}=\begin{bmatrix}\sigma_R^2 & 0 \\ 0 & \sigma_\Theta^2\end{bmatrix}$$ Now, let's define transformations given by $$X = R\cos (\Theta)$$ and $$Y = R \sin (\Theta)$$.

The question is, what would be $$C_{X,Y}$$, the covariance matrix of transformed random variable $$X$$ and $$Y$$?

The covariance matrix is given by

$$C_{X,Y}=\begin{bmatrix}E(XX)& E(XY) \\ E(YX )& E(YY) \end{bmatrix}$$

This can be written as below:

$$C_{X,Y}=\begin{bmatrix}E(R^2cos^2(\Theta) )& E(Rcos(\Theta)Rsin(\Theta)) \\ E(Rsin(\Theta)Rcos(\Theta) )& E(R^2sin^2(\Theta)) \end{bmatrix}$$

Since $$R$$ and $$\Theta$$ are independent the expectation will distribute. Now the task is to calculate expectation of $$Cos^2(\Theta)$$ , $$Sin^2(\Theta)$$ and $$Cos(\Theta)Sin(\Theta)$$ or equivalently $$Sin(2\Theta)$$. These can be found by by calculating the expectations of each of these functions for ex: for $$Cos^2(\Theta)$$ this will be $$E(cos^2(\Theta)) = \int_{ - \infty}^{\infty}\, Cos^2(\theta) f_\Theta(\theta) \, d\theta$$

Where $$f_{\Theta}(\theta)$$ is the PDF of random varible $$\Theta$$

Hint: you can also utilize symmetries while calculating these integrals, $$Sin(2\Theta)$$ is an odd function and it multiples a Gaussian with zero mean which is an even function. Similarly $$Cos^2(\Theta)$$ and $$Sin^2(\Theta)$$ are even functions

EDIT, Solving the integral:

$$\cos^2\theta=0.5+0.5\cos 2\theta=0.5+0.25(e^{2i\theta}+e^{-2i\theta})$$

$$I=\int_{-\infty}^{\infty} \cos^{2}(\theta) f_{\Theta}(\theta) d\theta=0.5+0.25\int_{-\infty}^\infty {1\over \sqrt{2\pi}} e^{-\theta^2\over 2}(e^{2i\theta}+e^{-2i\theta})d\theta$$

$$\int_{-\infty}^\infty e^{-\theta^2\over 2}e^{ki\theta}d\theta {= \int_{-\infty}^\infty e^{-\theta^2\over 2}e^{ki\theta}e^{-{(ki)^2\over 2}}e^{{(ki)^2\over 2}}d\theta \\= \int_{-\infty}^\infty e^{-(\theta-ki)^2\over 2}e^{-{k^2\over 2}}d\theta \\= \int_{-\infty}^\infty e^{-\theta^2\over 2}e^{-{k^2\over 2}}d\theta \\= \sqrt{2\pi}e^{-{k^2\over 2}} }$$ hence $$I=0.5+0.5e^{-2}$$

Original answer to the integral https://math.stackexchange.com/questions/3650453/integral-of-int-infty-infty-cos2-theta-f-theta-theta-d/3650494#3650494

• Yeah. I got it. Off-diagonal elements are zero. It would be nice if we have closed form expressions for diagonal elements too. The answer, I think, is not trivial as it involves product of two even functions. Apr 29, 2020 at 17:46
• @user5045 added the solution, but I have simply added this from a question I asked on mathematics stackexchange, I am adding the link, it's always a good idea to use different stackexachnge, I posted the question on maths stackexachnge rather than solve myslef, simply to illustrate that this question is a better fit for maths stackexachnge and how quick maths help you can get over there Apr 29, 2020 at 19:08
• Thanks a lot. I tried using MGF and got the same result. You elaborated it. Let me post my solution. If $X\sim \mathcal{N}(\mu,\sigma^2)$, then its MGF is $E \{e^{tX}\}=e^{t\mu + \frac{1}{2}\sigma^2 t^2}$. Hence, $$E \{e^{iX}\} = E \{\cos X + i \sin X\}=e^{i\mu - \frac{1}{2}\sigma^2}$$ Apr 30, 2020 at 3:30

Your covariance matrix should now look like

$$C_{X,Y}=\begin{bmatrix}\sigma^2_{(X,X)} & \sigma^2_{(X,Y)} \\ \sigma^2_{(Y,X)} & \sigma^2_{(Y,Y)} \end{bmatrix}$$

Since the covariance matrix formula is given by

$$C_{X, Y} = \frac{1}{n-1} \sum^{n}_{i=1}{(x_i-\bar{x})(y_i-\bar{y})}$$

and using the fact that both $$\bar{x}$$ and $$\bar{y}$$ are zero (zero mean), you should arrive at something like (provided that I did the math correctly)

$$C_{X,Y}=\begin{bmatrix}\sigma^2(R^2*cos^2(\Theta)) & \sigma^2(R^2*cos(\Theta)*sin(\Theta)) \\ \sigma^2(R^2*sin(\Theta)*cos(\Theta)) & \sigma^2(R^2*sin^2(\Theta)) \end{bmatrix}$$

These are still unnormalized values, you should divide by n-1 (n-number of samples) to get normalized values (if you were to apply this to a set of n samples/observations).

• There should be an expectation over all these values Apr 27, 2020 at 9:30
• @Dsp guy sam, the OP is interested in finding the covariance matrix, and not PSD (I take it that by an expectation you meant PSD. The covariance matrix elements are computed by going over all samples n for the 2 variables in question. Apr 27, 2020 at 9:42
• Every element of a covariance matrix is of the form $E[xy]$ when considering RVs, so an expectation has to be there, even the original $C_{R,\Theta}$ he mentions is derived like that that is why it's a diagonal matrix, so my understanding here is that he is looking for the covaraince matrix of RVs X, Y which should be in terms of the variances and cross correlations of X and Y and not in terms of particular realizations of the original RVs $R$, $\Theta$. Also I don't get how PSD comes into the picture here, PSD is the Fourier transform of correlations Apr 27, 2020 at 9:50
• @Dsp guy sam, not sure what RVs stand for. Still, the main diagonal contains E[x,x] and E[y,y] respectively, so the main diagonal contains the variances of the individual variables (this is true for every covariance matrix). Apr 27, 2020 at 9:54
• RVs is random variables, I will post an answer or else the comments will go long Apr 27, 2020 at 9:56