11
$\begingroup$

I am trying to do a measurement uncertainty calculation. I have a gaussian distributed phase angle (theta) with a mean of 0 and standard deviation of 16.6666 micro radians. The variance is the square of the standard. The formula for the measurment uses cos(theta) in the calculation. I need to know the mean, the variance and the distribution function that result from taking the cosine of theta in order to do my calculations correctly.

$\endgroup$
2
  • $\begingroup$ Your angles are small enough that sin(theta) is very close to theta, so you can simplify your analysis by approximating cos(theta) with sqrt(1-theta^2). $\endgroup$
    – Tracy Hall
    Aug 11, 2010 at 20:12
  • 3
    $\begingroup$ The other reasonable approximation is $$ \cos \theta \approx 1 - \frac{\theta^2}{2} $$ which will definitely give you a mean in closed form. $\endgroup$
    – Will Jagy
    Aug 12, 2010 at 3:18

7 Answers 7

13
$\begingroup$

I wrote out the first few terms in the power series for $ \cos \theta $ and then the first few terms of the series for $ \cos^2 \theta .$ I used your hypothesis of normal distribution, the mean of $ \theta $ is $ \mu = 0$ while the variance is some $ \sigma^2 .$

Then I looked up the expected values of $ \theta^2, \; \theta^4, \; \theta^6, \; \theta^8 $ at http://en.wikipedia.org/wiki/Gaussian_distribution#Moments and used that to find good approximations for your new mean $\mu_1$ and variance $\sigma_1^2$ in $$ \mu_1 = E[ \cos \theta ] = 1 - \frac{\sigma^2}{2} + \frac{\sigma^4}{8} - \frac{\sigma^6}{48} + \cdots $$ and $$ \mu_1^2 + \sigma_1^2 = E[ \cos^2 \theta ] = 1 - \sigma^2 + \sigma^4 - \frac{2 \sigma^6}{3} + \cdots $$ So when you subtract you get $ \sigma_1^2 \approx \frac{\sigma^4}{2} $

I will think about it some more, there is a large theory for calculating moments. But I do not see much to be done in the way of an explicit pdf or cdf.

$\endgroup$
1
  • $\begingroup$ I have a partial solution :) $\endgroup$
    – ABIM
    Feb 24, 2016 at 15:02
23
$\begingroup$

A quick way to find the mean of $\cos(\theta)$, where $\theta\sim \mathcal{N}(0, \sigma^2)$, is through calculating the mean of a complex variable $e^{j\theta}=\cos(\theta)+j\sin(\theta)$. We have

$E [e^{j\theta}]=e^{0+(j\sigma)^2/2}=e^{-\sigma^2/2}$

which implies that the mean of the imaginary part $E [\sin(\theta)]$ equals zero and the mean of the real part $E[\cos(\theta)]$ equals $e^{-\sigma^2/2}$.

The answer $\mu_1$ derived by Will Jagy is in fact the Taylor series expansion of $e^{-\sigma^2/2}$.

The variance of $\cos(\theta)$ can be obtained as:

$E[\cos^2(\theta)]-E[\cos(\theta)]^2= E[\frac{1}{2}+\frac{\cos(2\theta)}{2}]- E[\cos(\theta)]^2= \frac{1}{2}[1-e^{-\sigma^2}]^2$

$\endgroup$
2
  • 3
    $\begingroup$ If anyone else is looking for this: I used this to work out the mean and variance of $\cos x$ and $\sin x$ where $x \sim \mathcal{N}(\mu, \sigma^2)$ at this link. Nothing complicated, just a bunch of trig identities that I haven't remembered since tenth grade. $\endgroup$
    – Danica
    Jan 20, 2014 at 5:19
  • 2
    $\begingroup$ For completeness, adding a reference to the calculation of mean of a complex variable when the exponent terms follow the normal distribution: math.stackexchange.com/a/2050140/29735 $\endgroup$
    – AruniRC
    Dec 29, 2017 at 18:25
5
$\begingroup$

Hi, I know this was asked a long time ago but I have just discovered it because I require a similar solution. It is possible to generate an expression, albeit as an infinite summation. For practical purposes, the first few terms of the summation should suffice.

Let $X$ denote a random variable with pdf $f_X(x)$. Let $Y=g(X)$ be a function of $X$. We can specify the cdf of $Y$, denoted $F_Y(y)$ as follows:

$F_Y(y)=\mathbb{P}(g(X)\leq y)=\int\limits_{\Omega}f_X(x)\text{d}x$,

where the domain of integration $\Omega$ is defined as

$\Omega=\left\lbrace x:g(x)\leq y \right\rbrace$

In our case, $g(x)=\cos x$, so we need an expression for the domain of $x\in\mathbb{R}$ such that $\cos x\leq y$. This is given by

$2k\pi+\arccos(y) \leq x < 2(k+1)\pi-\arccos(y)\, k\in\mathbb{Z}$

So integrating over this domain, we obtain

$F_Y(y)=\sum\limits_{k=\infty}^{\infty} \int\limits_{2k\pi+\arccos(y)}^{2(k+1)\pi-\arccos(y)} f_X(x)\text{d}x$

Now in our case $X\sim\mathcal{N}(0,\sigma)$, so

$f_X(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\exp\left(\dfrac{-x^2}{2\sigma^2}\right)$

and the integral of this pdf between limits is given by the cdf of the normal distribution, which we denote $\Phi$:

$\int\limits_{a}^{b}f_X(x)\text{d}x = \Phi(b/\sigma)-\Phi(a/\sigma)$

The cdf of $Y$ is therefore

$F_Y(y)=\sum\limits_{k=-\infty}^{\infty} \Phi\left(\dfrac{2(k+1)\pi-\arccos(y)}{\sigma}\right) - \Phi\left(\dfrac{2k\pi-\arccos(y)}{\sigma}\right)$

To compute the pdf, take the derivative with respect to $y$:

$f_Y(y)=\dfrac{dF_Y(y)}{dy} = \sum\limits_{k=-\infty}^{\infty} \dfrac{1}{\sqrt{1-y^2}}\left( f_{X}(2(k+1)\pi-\arccos(y) ) + f_{X}(2k\pi+\arccos(y)) \right)$

There are probably better ways to do this. It's possible the final summation can be rewritten or simplified. But this seems to match with a numerical check.

$\endgroup$
1
  • $\begingroup$ Think it should be $$F_Y(y) = \sum_{k=-\infty}^\infty \Phi\left( \frac{2(k+1) \pi - \arccos(y)}{\sigma} \right) - \Phi\left( \frac{2k\pi + \arccos(y)}{\sigma} \right)$$, no? (Note the addition instead of subtraction in the second $\Phi$ argument.) This makes the pdf $$f_Y(y)=\dfrac{dF_Y(y)}{dy} = \sum\limits_{k=-\infty}^{\infty} \dfrac{1}{\sqrt{1-y^2}}\left( f_{X}(2(k+1)\pi-\arccos(y) ) - f_{X}(2k\pi+\arccos(y)) \right)$$. $\endgroup$
    – Danica
    Jan 24, 2014 at 22:47
4
$\begingroup$

Stochastic Calculus Approach:

If $W_t$ is a standard Wiener process, we know that the increment $W_t=W_0$ is normally distributed (with mean 0 and variance $t$). Let $ \begin{equation} f(t,x):=e^{t/2}cos(x) \end{equation} $ Then by Ito's lemma we have that $X_t:=f(t,W_t)$ satisfies: \begin{equation} e^{t/2}cos(W_t) = 1+ \int_0^t \frac{-e^{t/2}}{2}sin(W_t)dW_t. \end{equation}

  1. Mean Taking expectation on both sides of the above equation yields: \begin{align} \mathbb{E}[e^{t/2}cos(W_t)] & = \mathbb{E}[1+ \int_0^t \frac{-e^{t/2}}{2}sin(W_t)dW_t] \end{align} since $\int_0^t sin(W_t)dW_t$ is a stochastic integral, it must be a martingale; wherefrom it follows that the above expectation reduces to: \begin{align} \mathbb{E}[e^{t/2}cos(W_t)] & = \mathbb{E}[1]+ \mathbb{E}[\int_0^t \frac{-e^{t/2}}{2}sin(W_t)dW_t] = 1 \\ \therefore \mathbb{E}[cos(W_t)] & = e^{-t/2}. \end{align} Since $\theta:=W_t-W_0$ is a $\mathscr{N}_1(0,t)$-distributed random variable. Then we may conclude that: \begin{align} \mathbb{E}[cos(\theta)] & = e^{-t/2}. \end{align}
  2. Variance: To calculate the variance we note that by the Ito isometry we have that: \begin{align} \mathbb{E}[\left(e^{t/2}cos(W_t)\right)^2] & = \int_0^t \mathbb{E}[\left(e^{t/2}cos(W_t)\right)^2] dt \\ \leq \int_0^t \mathbb{E}[\left(-e^{t/2}\right)^2] dt & = e^{t/2}-1. \\ \therefore \left(e^{t/2}\right)^2\mathbb{E}[\left(cos(\theta)\right)^2] & \leq e^{t/2}-1 \\ \therefore \mathbb{E}[\left(cos(\theta)\right)^2] &\leq e^{-t/2}(1-e^{-t/2}) \\ \end{align} Therefore we have that: \begin{align} Var(e^{t/2}cos(\theta))& = Var(e^{t/2}cos(W_t-W_0)) = \mathbb{E}[\left(e^{t/2}cos(W_t)\right)^2] - \mathbb{E}[cos(\theta)]^2 \\ & =\mathbb{E}[\left(e^{t/2}cos(W_t)\right)^2]- \left(e^{-t/2}\right)^2 \\ & \leq e^{-t/2}(1-e^{-t/2}) - \left(e^{-t/2}\right)^2. \end{align} Since the lower-bound of $e^{t/2}cos(W_t)$ is $0$ then we have the following estimate on the variance: \begin{align} \therefore 0 \leq Var(cos(\theta)) & \leq e^{-t/2}\left(1-2e^{-t/2}\right). \end{align}
$\endgroup$
3
$\begingroup$

Original Approach

Given a normal distribution with mean $\mu$ and variance $\sigma^2$, $X = \mathcal{N}(\mu,\sigma^2)$, if you pass it through trigonometric functions, you can approximate the result with the new normal distributions below

1) normal distribution passed through Cosine function:

$X_{\cos} = \mathcal{N}(\cos(\mu),\sigma^2\sin^2(\mu))$

so the new average is $\cos(\mu)$ and the new standard deviation is $|\sigma\sin(\mu)|$.

2) normal distribution passed through a Sine function:

$X_{\sin} = \mathcal{N}(\sin(\mu),\sigma^2\cos^2(\mu))$

so the new average is $\sin(\mu)$ and the new standard deviation is $|\sigma\cos(\mu)|$.

The Matlab script that I used to find these relations is below.

%% Cody Martin
% 9/2/2010
% m-file used to discover the mean and variance of a normal distribution
% passed through cosine and sine functions...results:
%   - N(mu,sig^2) -> cos(N(mu,sig^2)) = N(cos(mu),sig^2*sin^2(mu))
%   - N(mu,sig^2) -> sin(N(mu,sig^2)) = N(sin(mu),sig^2*cos^2(mu))

%% distribution of cosine and sine of a normal distribution?
cresults = zeros(0,5);
sresults = zeros(0,5); 
% loop from an average angle -90 degrees to +90 degrees
for theta = -pi/2:pi/180:pi/2
    theta1sig = pi/36;                          % standard deviation of orinigal normal distribution
    vtheta = theta + theta1sig*randn(99999,1);  % create 99999 points using this avg and std
    vctheta = cos(vtheta);                      % take the cosine of those points
    vstheta = sin(vtheta);                      % take the sine of those points
    theta_ = min(vtheta):0.01:max(vtheta);      % for plotting ideal distributions
    ctheta_ = min(vctheta):0.01:max(vctheta);   % for plotting
    stheta_ = min(vstheta):0.01:max(vstheta);   % for plotting

    figure(1); clf;
    subplot(211); hold on;
    plot(theta_,cdf('normal',theta_,theta,theta1sig),':');  % plot cdf of normal distribution with avg and std
    plot(sort(vtheta),[1:length(vtheta)]/length(vtheta));   % plot cdf of 99999 points
    plot(sort(vctheta),[1:length(vctheta)]/length(vctheta),'k','LineWidth',2); % plot cdf of cos(99999 points)
    plot(ctheta_,cdf('normal',ctheta_,cos(theta),...        % plot cdf of norm dist with new avg and std after being passed through cos()
         sqrt(theta1sig^2*sin(theta)^2)),'r:');
    plot(cos(theta)*[1 1],[0 1],'k:');                      % vertical line @ cos(theta) - shows new average matches cos(old avg)
    title('Cosine of a Normal Distribution (for Different Initial Averages)');
    legend('Norm CDF Theory','Norm CDF 99999','Cos(Norm CDF 99999)','Cos(Norm CDF) Theory');
    axis([-pi/2 pi/2 0 1])

    subplot(212); hold on;
    plot(theta_,cdf('normal',theta_,theta,theta1sig),':');
    plot(sort(vtheta),[1:length(vtheta)]/length(vtheta));
    plot(sort(vstheta),[1:length(vstheta)]/length(vstheta),'k','LineWidth',2);
    plot(stheta_,cdf('normal',stheta_,sin(theta),...
         sqrt(theta1sig^2*cos(theta)^2)),'r:');
    plot(sin(theta)*[1 1],[0 1],'k:');
    title('Sine of a Normal Distribution (for Different Initial Averages)');
    legend('Norm CDF Theory','Norm CDF 99999','Sin(Norm CDF 99999)','Sin(Norm CDF) Theory');
    axis([-pi/2 pi/2 0 1])

%   fprintf('theta: %3.0f\tstd: %5.3f\tsin(theta): %5.3f\tavg: %5.3f\tstd: %5.3f\n',theta*180/pi,theta1sig,sin(theta),mean(vstheta),std(vstheta));
    cresults = [cresults; theta theta1sig cos(theta) mean(vctheta) std(vctheta)];
    sresults = [sresults; theta theta1sig sin(theta) mean(vstheta) std(vstheta)];
end

figure(2); clf;
subplot(211); hold on;
plot(cresults(:,1),cresults(:,end));
plot(cresults(:,1),abs(theta1sig*sresults(:,3)),'r:');
title('Standard Deviation of Cosine of a Normal Distribution as a Function of the Original Average');
legend('From 99999 Points','Fit: std = |\sigmasin(\mu)|');
ylabel('std(cos(\theta_{vector})) [rad]');
xlabel('\theta [rad]');

subplot(212); hold on;
plot(sresults(:,1),sresults(:,end));
plot(sresults(:,1),abs(theta1sig*cresults(:,3)),'r:');
title('Standard Deviation of Sine of a Normal Distribution as a Function of the Original Average');
legend('From 99999 Points','Fit: std = |\sigmacos(\mu)|');
ylabel('std(sin(\theta_{vector})) [rad]');
xlabel('\theta [rad]');

figure(3); clf;
subplot(211); hold on;
plot(cresults(:,1),abs(theta1sig*sresults(:,3))-cresults(:,end));
title('Error Between \sigma^2sin^2(\mu) and std of 99999 Draws of cos(\theta)')
ylabel('Residual [rad]');
xlabel('\theta [rad]');


subplot(212); hold on;
plot(sresults(:,1),abs(theta1sig*cresults(:,3))-sresults(:,end));
title('Error Between \sigma^2cos^2(\mu) and std of 99999 Draws of cos(\theta)')
ylabel('Residual [rad]');
xlabel('\theta [rad]');

Update

As others have pointed out, this fails where $\cos(\mu)$ and $\sin(\mu)$ are near 0. Residuals between my proposed solution and the empirical results from 99999 draws are shown below.

enter image description here

$\endgroup$
2
  • $\begingroup$ Cody, is it wright what you say? Sigma is varying with the mean? If I measure an angle of 90 degrees, then $N_{\cos}(0,{\sigma}^2)$ and $N_{\sin}(1,0)$? And if I measure an angle of 0 degrees, then $N_{\cos}(1,0)$ and $N_{\sin}(0,{\sigma}^2)$ ? Where do I find the theory of that? $\endgroup$
    – user24033
    May 28, 2012 at 14:21
  • $\begingroup$ Cody, I'm afraid your answer is incomplete. The problem I see lays with the variance. If $X \sim N(\mu,\sigma^2)$ indeed results with $cos(X) \sim N(cos(\mu), \sigma^2 sin^2(\mu))$ then for, e.g., $\mu = \frac{\pi}{2}$ the approximation is $N(1,0)$ regardless of $\sigma$. This seems to be a poor approximation because an increase in the variance of $X$ should always result in an increase of the variance of $cos (X)$. $\endgroup$
    – user33615
    May 2, 2013 at 5:04
1
$\begingroup$

Given that $x\sim \mathcal{N}(\mu,\sigma^2)$, I used Mathematica to explicitly compute the integral corresponding to the expectation of $\sin(ax)$ and $\cos(ax)$. This would generalize all of the previous responses already given.

\begin{align*} &\mathbb{E}\left \{ \sin(ax) \right \}=\sin( a\mu) \exp \left ( \dfrac{1}{2} a^2 \sigma^2 \right ). \\ & \mathbb{E}\left \{ \cos(ax) \right \}=\cos( a\mu) \exp \left ( \dfrac{1}{2} a^2 \sigma^2 \right ). \end{align*}

Putting $\mu=0$ and $a=1$ will recover the desired result.

$\endgroup$
1
  • 1
    $\begingroup$ Something's wrong here, the RHSs are greater than one when $\sigma$ gets too large... $\endgroup$ Apr 29, 2019 at 11:19
0
$\begingroup$

For $y=\cos(x)$, the CDF of $y$

\begin{array}{l} F_Y \left( y \right) = \left\{ {\begin{array}{*{20}l} {0,y < - 1} \\ {P\left( {2k\pi + \arccos y \le x \le 2\left( {k + 1} \right)\pi - \arccos y} \right),k \in \Bbb Z, - 1 \le y \le 1} \\ {1,y > 1} \\ \end{array}} \right. \\ P\left( {2k\pi + \arccos y \le x \le 2\left( {k + 1} \right)\pi - \arccos y} \right) \\ = \sum\limits_{k = - \infty }^{ + \infty } {\int_{2k\pi + \arccos y}^{2\left( {k + 1} \right)\pi - \arccos y} {f_X (x)} } dx \\ f_Y (x) = \sum\limits_{k = - \infty }^{ + \infty } {\left[ { - \left( { - \frac{1}{{\sqrt {1 - y^2 } }}} \right)f_X \left( {2\left( {k + 1} \right)\pi - \arccos y} \right) - \left( { - \frac{1}{{\sqrt {1 - y^2 } }}} \right)f_X \left( {2k\pi + \arccos y} \right)} \right]} \\ = \frac{1}{{\sqrt {1 - y^2 } }}\sum\limits_{k = - \infty }^{ + \infty } {\left[ {f_X \left( {2\left( {k + 1} \right)\pi - \arccos y} \right) + f_X \left( {2k\pi + \arccos y} \right)} \right]} \\ \end{array}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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