# Summation of cosine of uniform random variable

I read that the PDF of the sum of cosines of a random variable, which is uniformly distributed, is a non uniform distribution; something like inverse square root of the random variable. My doubt is, not going into pdf, but just if we calculate sum of cosine of random variable varying between $$-\pi$$ to $$\pi$$, i.e., SUM $$(\cos (t_j))$$, should it not be 0 for large number of values for the $$t_j$$ intuitively? I am confused. If this is a valid question can anyone help? Thanks a lot.

Also, if we have SUM $$(\cos(t_j))$$, $$t_j$$ is uniform random variable between $$-\pi$$ to $$\pi$$, then will introducing frequency $$w$$ (omega) affect the answer to above question? i.e., SUM $$(\cos (w \cdot t_j))$$?

Consider a series of independent uniform random variables $$U_1,U_2,U_3,... \sim \text{IID U}(0,1)$$ and form the corresponding series $$X_1,X_2,X_3,...$$ as:

$$X_i = \cos(\pi U_i).$$

For all $$|x| \leqslant 1$$ the latter random variables have the distribution function:

\begin{aligned} F_X(x) = \mathbb{P}(X \leqslant x) &= \mathbb{P}(\cos(\pi U) \leqslant x) \\[6pt] &= \mathbb{P} \Big( U \geqslant \frac{1}{\pi} \cdot \arccos(x) \Big) \\[6pt] &= 1 - \frac{1}{\pi} \cdot \arccos(x), \\[6pt] \end{aligned}

and the corresponding density function:

\begin{aligned} f_X(x) = \frac{dF_X}{dx}(x) &= -\frac{1}{\pi} \cdot \frac{d}{dx} \arccos(x) \\[6pt] &= \frac{1}{\pi} \cdot \frac{1}{\sqrt{1-x^2}}. \\[6pt] \end{aligned}

This random variable has mean $$\mathbb{E}(X) = 0$$ and variance $$\mathbb{V}(X) = \tfrac{1}{2}$$. Now, let $$S_n = \sum_{i=1}^n X_i$$ be a partial sum of these variables, and note that it has mean $$\mathbb{E}(S_n) = 0$$ and variance $$\mathbb{V}(S_n) = \tfrac{n}{2}$$. By the central limit theorem the limiting distribution of the standardised sum is the standard normal distribution. For large $$n$$ we have the approximate distribution:

$$S_n \overset{\text{Approx}}{\sim} \text{N} \Big( 0, \frac{n}{2} \Big).$$

The variance of the sum increases with $$n$$, so there is no convergence to zero --- the sum will be distributed around zero, buts its variance gets bigger and bigger. However, if you instead look at the sample mean $$\bar{X}_n = S_n/n$$, the variance of this latter quantity decreases to zero, so you will have convergence to the mean of zero. This latter result is a manifestation of the law of large numbers.

Simulation: We can simulate this problem in R as follows. In this code we plot the kernel density of $$m = 10^5$$ simulations for $$n=100$$ and we superimpose the normal density as a red dashed line. You can see that this is a very close approximation to the kernel density of the simulations.

#Simulate matrix of cosine values
set.seed(1);
m <- 10^5;
n <- 100;
U <- matrix(runif(n*m,0,1), nrow = m);
X <- cos(pi*U);

#Calculate sample total of cosine values
S <- rowSums(X);

#Create data-frame for plotting
DD <- density(S);
NN <- dnorm(DD$$x, mean = 0, sd = sqrt(n/2)); GRAPH <- data.frame(S = DD$$x, Density = DD$y, Approx = NN); #Plot density of sample totals library(ggplot2); FIGURE <- ggplot(data = GRAPH, aes(x = S, y = Density)) + geom_line(size = 1) + geom_line(aes(y = Approx), colour = 'red', linetype = 'dashed') + ggtitle('Density of Sample Means of Cosine Simulations') + xlab('Sample Mean') + ylab('Density'); FIGURE;  • Does that means, the summation to become 0 is most likely due to gauss curve centered around mean 0 ? But does this mean that when we simulate and see the value of the sum of cos (uniform random variable values between -1 to 1) we some times also get not 0 even for large number of values? – Rag Tej May 2 at 9:55 • But intuitively how to visualize this? Let us take a simpler case of ∑tj, tj belongs to [-1, 1] and is uniformly distributed. Intuitively, my mind thinks that this sum should be zero because the tjs are uniformly distributed in -ve and +ve domains. But I think mathematically, even this sum is also irwin-hall distributed?! – Rag Tej May 2 at 9:57 • The variance of the sum increases with$n$, so there is no convergence to zero. However, if you use the sample mean$S/n$instead of the sum$S\$ then the variance decreases to zero, so you have convergence to the mean of zero. – Ben May 2 at 10:00
• Indeed! I see what you mean. I have one more doubt. In arriving at the solution, you took different random variables, each between (0,1). Is this equivalent of what I posed in question as Sum (different values of one random variable)? Like, did you replace each value of one random variable with different random variables, independent of each other (and hence equivalent)? Am I on right tracks of understanding? Also, may I ask how to arrive at ℙ(𝑈⩾1𝜋⋅arccos(𝑥))=1−1𝜋⋅arccos(𝑥)? – Rag Tej May 2 at 10:09
• Unfortunately I cannot fully understand the description in your question, so I am not sure exactly what it is. – Ben May 2 at 10:15