6
$\begingroup$

Suppose $X$ is a random variable drawn from a normal distribution with mean $E$ and variance $V$. How could I calculate variance of $\sin(X)$ and $\cos(X)$?

(I thought the question was simple and tried to do a search, but did not find any good answer.)

What if there is no assumption about the distribution of $X$, and only sample mean and variance are provided?

$\endgroup$
  • 3
    $\begingroup$ Both variables are bounded in $[-1, 1]$ so one can show that the variance is $\le \frac{2^2}{4} = 1$. $\endgroup$ – angryavian Feb 21 at 22:56
  • 2
    $\begingroup$ You can always write down the relevant integrals and feed them to a CAS. Mathematica told me $\operatorname{Var}(\sin(X)) = \frac{1}{2} (1-e^{-2\sigma^2}\cos(2\mu))$ and $\operatorname{Var}(\cos(X)) = -e^{-\sigma^2} \cos^2\mu + \frac{1}{2}(1+e^{-2\sigma^2} \cos(2\mu))$. $\endgroup$ – Nate Eldredge Feb 22 at 4:05
  • 2
    $\begingroup$ @NateEldredge Or, without an integral (Mathematica does (simple) expectations): Expectation[ (Sin[X] - Expectation[ Sin[X], X \[Distributed] NormalDistribution[\[Mu], \[Sigma]]])^2, X \[Distributed] NormalDistribution[\[Mu], \[Sigma]]] $\endgroup$ – Clement C. Feb 22 at 17:55
  • 1
    $\begingroup$ (You may want to add FullSimplify[ExpToTrig[ ]] around that to have a representation in terms of $\sin,\cos$ instead of exponentials) $\endgroup$ – Clement C. Feb 22 at 18:01
  • 1
    $\begingroup$ After you ask a question here, if you get an acceptable answer, you should "accept" the answer by clicking the check mark $\checkmark$ next to it. This scores points for you and for the person who answered your question. You can find out more about accepting answers here: How do I accept an answer?, Why should we accept answers?, What should I do if someone answers my question?. $\endgroup$ – Clement C. Feb 25 at 22:24
11
$\begingroup$

What is below is for $\mu=0$ (and variance renamed $\sigma^2$). Then $\mathbb{E}[\sin X]=0$, and you have $$ \operatorname{Var} \sin X = \mathbb{E}[\sin^2 X] = \frac{1}{2}\left(1-\mathbb{E}[\cos 2X]\right) $$ and $$ \mathbb{E}[\cos 2X] = \sum_{n=0}^\infty (-1)^k\frac{2^{2k}}{(2k)!} \mathbb{E}[X^{2k}] = \sum_{n=0}^\infty (-1)^k\frac{2^{2k}}{(2k)!} \sigma^{2k} (2k-1)!! = \sum_{n=0}^\infty (-1)^k \frac{2^{k}\sigma^{2k}}{k!} = e^{-2\sigma^{2}} $$ and therefore $$ \operatorname{Var} \sin X = \boxed{\frac{1-e^{-2\sigma^2}}{2}} $$ You can deal with the variance of $\cos X$ in a similar fashion (but you now have to substract a non-zero $\mathbb{E}[\cos X]^2$), especially recalling that $\mathbb{E}[\cos^2 X] = 1- \mathbb{E}[\sin^2 X]$.


Now, for non-zero mean $\mu$, you have $$ \sin(X-\mu) = \sin X\cos \mu - \cos X\sin\mu $$ (and similarly for $\cos(X-\mu)$) Since $X-\mu$ is a zero-mean Gaussian with variance $\sigma^2$, we have computed the mean and variance of $\sin(X-\mu)$, $\cos(X-\mu)$ already. You can use this with the above trigonometric identities to find those of $\cos X$ and $\sin X$. (it's a bit cumbersome, but not too hard.)


Without knowing anything about the distribution of $X$, I don't think there's much you can do.

$\endgroup$
  • $\begingroup$ I might have missed something, but could you tell me why $Var sin(X) = E[sin^2 X]$ ? Also why does the result not contain anything related to mean or variance of $X$? $\endgroup$ – Hùng Phạm Feb 21 at 23:16
  • $\begingroup$ @HùngPhạm Oh, my bad, I did it for mean $0$ and variance $1$. Let me fix that. $\endgroup$ – Clement C. Feb 21 at 23:17
  • $\begingroup$ I think you'd need to consider $\mathbb E(sin^2x)-[\mathbb E(sinx)]^2$ $\endgroup$ – Sharat V Chandrasekhar Feb 21 at 23:20
  • $\begingroup$ @SharatVChandrasekhar It becomes a bit more complicated than that, actually. $\endgroup$ – Clement C. Feb 21 at 23:21
  • 1
    $\begingroup$ This answer does look sufficient to me. I will go with this answer and complete the rest. If it's too cumbersome, I guess I will consider using a 2nd (or 1st) order Taylor representation. Thank you a lot and also @SharatVChandrasekhar $\endgroup$ – Hùng Phạm Feb 22 at 5:05
5
$\begingroup$

Here is a general formulation using the law of the unconscious statistician that can be applied to other functions too. For specific calculations with $\sin$ and $\cos$ here though, I would say Clement C.'s answer is better!

The mean of $\color{blue}{h(X)}$ (for some function $h$) would be given by the integral $$\mathbb{E}[h(X)]=\int_{-\infty}^{\infty}\color{blue}{h(x)}f_X(x)\, dx,$$ where $f_X$ is the probability density function of $X$.

The second moment would be found similarly as $$\mathbb{E}\left[(h(X))^2\right] = \int_{-\infty}^{\infty}\color{blue}{(h(x)^2)}f_X(x)\, dx.$$

Once you know the first two moments here, you can calculate the variance using $\mathrm{Var}(Z) = \mathbb{E}[Z^2] - (\mathbb{E}[Z])^2$.

Replace $h(x)$ with $\cos x$ for the corresponding expectations for $\cos X$, and similarly with $\sin x$.

If the distribution of $X$ is not known, we cannot generally compute the exact mean and variance of $h(X)$. However, you may want to see this for some approximations that could be used. Some useful ones for you may be that if $X$ has mean $\mu_X$ and variance $\sigma^2_X$, then $$\mathbb{E}[h(X)]\approx h(\mu_X) + \dfrac{h''(\mu_X)}{2}\sigma_X^2$$ and $$\mathrm{Var}(h(X))\approx (h'(\mu_X)^2)\sigma^2_X + \dfrac{1}{2}(h''(\mu_X))^2 \sigma^4_X.$$

$\endgroup$
1
$\begingroup$

I know this is not the kind answer you are looking for, but you can compute this empirically pretty easily via probabilistic programming. Here is an example with Python and pymc3, taking $E=0.75$ and $V=0.25^2$:

import pymc3 as pm
import numpy as np

with pm.Model() as model:
    x = pm.Normal('x', mu=0.75, sd=0.25)
    y = pm.Deterministic('y', np.sin(x))
    trace = pm.sample(10000)

pm.plot_posterior(trace)
pm.summary(trace)

This snippet will produce a plot showing the distribution of $X$ and $Y=\sin(X)$

posterior

And this table, which shows mean, standard deviation, bounds for the 95% confidence interval, and some diagnostics to make sure the results are reliable (they are):

       mean        sd  mc_error   hpd_2.5  hpd_97.5        n_eff      Rhat
x  0.747098  0.248358  0.003078  0.269450  1.240856  7756.202193  0.999998
y  0.658854  0.178794  0.002208  0.322414  0.980199  7731.781691  1.000049
$\endgroup$
  • 1
    $\begingroup$ Actually, I thought of something similar to this previously. I did not follow this approach for 2 reasons: a) I did not know if this was a well-known, trivial problem that could be deterministically solved or not; b) I want to plug this calculation into a fast program, so sampling a lot # of points might slow it down especially when I repeat the operation many times. But nevertheless, your answer is still very helpful. Thanks! $\endgroup$ – Hùng Phạm Feb 22 at 15:27
1
$\begingroup$

$\cos^2(x) = \frac{\cos(2x)+1}2$, which averages out to $\frac12$. So as the variance of $X$ goes to infinity, the variance of $\cos(X)$ goes to $\frac12$, assuming the distribution of $X$ is "well-behaved". The lower bound is $0$ (the variance can be made arbitrarily small by choosing the variance of $X$ to be small enough), and as @angryavian says, the upper bound is $1$. Since $|\cos(x)| \leq 0$, and the inequality is strict for all but a measure zero set, the variance of $\cos(X)$ is less than the variance of $X$.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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