6

I have to find pdf of $Y = \cos(X)$ where $X$ is a random variable distributed uniformly in $[-\pi,\pi]$. I solved this using distribution function method, and the result was:

$f_{Y}(y) = \dfrac{1}{\pi \sin(\cos^{-1}y)}, y \in\ [-1,1]$

I am not able to understand this result intuitively. At first thought, it occurred that $\cos(X)$ should be distributed uniformly as well, but that is clearly wrong. I completely fail to understand why the pdf of $\cos(X)$ goes to $\infty$ at $-1$ and $1$ as well.

Please help me form an intuitive understanding of this result, I am not from a statistics background.

Glen_b
  • 282,281
vid
  • 63
  • Almost the same question is asked and answered at http://stats.stackexchange.com/questions/14483/intuitive-explanation-for-density-of-transformed-variable. Is that perhaps a duplicate? – whuber Apr 16 '13 at 03:10

2 Answers2

7

Here's a mostly intuitive explanation of the general appearance of the result. Consider just the right half of the original $y$ range (the other half is symmetric about zero to what happens here).

Where do the values end up? Which values go close to 1? To 0?

Clearly, from inspection of the $\cos$ function, small $y$ values will become values close to $1$, while values of $y$ near $\pi$ are mapped to near $-1$ and values near $\pi/2$ are mapped to near $0$.

Near $y=\pi/2$ the $\cos$ function is almost linear, and so uniformly distributed $Y$ values will remain nearly uniform after transformation (just rescaled almost-linearly - in this case, the linear transform that it's close to in this vicinity flips values around and shifts them along).

Near $y=0$ the $\cos$ function is almost quadratic, $\text{cos}\, y \approx 1-y^2/2$. So what happens to $y$ values between 0 and $\varepsilon$ for small $\varepsilon$?

They get mapped to values between $1-\varepsilon^2/2$ and $1$. So they're bunched into a space that is about $\varepsilon/2$ as large as where they came from. So it has to get (on average) $2/\varepsilon$ times as dense in there - a big number.

e.g. values between 0 and 0.01 roughly go to between 1-0.00005 and 1. So they're squeezed into one two-hundredth the space and so need to average 200 times the density in there, and it gets bigger the closer in you go.

There's a similar effect on $y$ values close to $\pi$ but they map to near $-1$.

So the overall appearance is intuitively clear - the density should look flat near zero and increase dramatically - indeed, without bound, near the endpoints.

(Note that $\text{sin}(\text{cos}^{−1}y) = \sqrt{1-y^2}$ here. This doesn't affect the above intuitive explanation for why it must look like this, but is useful if you're trying to use the usual algebraic methods for calculation of the density of the transformed variable.)

Glen_b
  • 282,281
1

I know this is an old question, but I think a picture is worth a thousand words, and in this case would provide a very good intuition for the formula.

Quantiles of cosine values between 0 and pi

Matlab code to generate this figure:

v = cos(linspace(0,pi,1000));
p = linspace(0,1,100);

figure; plot(p,quantile(v,p)); grid on; xlabel('Quantile'); ylabel('Value');

What is this figure?

Forget about random variables for a minute.

What is the quantile corresponding to a given value $\cos\phi$ between -1 and 1? In order words, how are cosine values distributed between -1 and 1, when we sweep the interval $[0,\pi)$?

That's what is shown in the figure above. Cosine is flatter near 0 and $\pi$ (peaks and troughs), therefore small changes in values near 1 and -1 correspond to larger quantile variations compared to similar changes in value near 0.

How does that answer the question?

The CDF of the distribution mentioned in the OP is the inverse of the function plotted above (mirror the curve along the diagonal).

It's derivative, the PDF, visibly tends to infinity near -1 and 1.