# Variance of sum of function of uniformly distributed random variables

Let $(X_i)_i$ be independent random variables such that $X_i \sim U[0, 1]$, and define $Y_i = X_i X_{i+1}$ and $Z_n = \sum_{i=1}^n Y_i$.

I want to find the variance of $Z_n$.

I found that $\mathbb E [Z_n]=\frac{n}{4}$ , and when applying the formula of the variance, I have $\sum_{i=1}^n \operatorname{Var}(Y_i) = \frac{7n}{144}$ using the fact the $X_i$'s are independent.

How do I find the covariance of the other variables?

$$\text{Var}\left(\sum_{i=1}^n Y_i \right) = \sum_{i=1}^n \sum_{j=1}^n \text{Cov}(Y_i, Y_j)$$

Now if $|i-j|\ge 2$, $Y_i = X_i X_{i+1}$ and $Y_j = X_j X_{j+1}$ are independent, so these covariances are $0$.

If $i=j$, $$\text{Cov}(Y_i, Y_i) = \text{Var}(X_i X_{i+1}) = \mathbb E[X_i^2 X_{i+1}^2] - \mathbb E[X_i X_{i+1}]^2 = \mathbb E[X_i^2]^2 - \mathbb E[X_i]^4 =\frac{7}{144}$$ There are $n$ of these terms, contributing a total of $7n/144$ to the variance of $Z_n$.

If $i=j\pm 1$, \eqalign{\text{Cov}(Y_i,Y_j) &= \text{Cov}(X_{j+1} X_{j+2},X_{j} X_{j+1}) = \mathbb E[X_j X_{j+1}^2 X_{j+2}] - E[X_j X_{j+1}]^2 \cr &= \mathbb E[X_j]^2 \mathbb E[X_j^2] - \mathbb E[X_j]^4 = \frac{1}{48} }

There are $2n-2$ of these terms, contributing a total of $(2n-2)/48$. Thus $$\text{Var}(Z_n) = \frac{7n}{144} + \frac{2n-2}{48} = \frac{13 n}{144} - \frac{1}{24}$$

You have $$\operatorname{Var} Z_n = \operatorname{Var} \sum_{k=1}^n Y_k$$ but sadly you cannot write that this is equal to $\sum_{k=1}^n \operatorname{Var} Y_k$ as the $Y_k$'s are not independent (and not even pairwise independent either, which would have been sufficient).

However, you can write: $$\mathbb{E} Z_n^2 = \mathbb{E}\left[ \left(\sum_{k=1}^n Y_k \right)^2 \right] = \mathbb{E}\left[ \sum_{k=1}^n \sum_{\ell=1}^n Y_kY_\ell \right] = \sum_{k=1}^n \sum_{\ell=1}^n \mathbb{E}\left[Y_kY_\ell \right] = \sum_{k=1}^n \sum_{\ell=1}^n \mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right]\,.$$ Now, let us focus on a term $\mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right]$.

• if $k=\ell-1$, then $$\mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right] = \mathbb{E}\left[X_kX_\ell^2 X_{\ell+1} \right] = \mathbb{E}\left[X_k\right]\mathbb{E}\left[X_\ell^2\right]\mathbb{E}\left[ X_{\ell+1} \right] = \frac{1}{2}\cdot \frac{1}{3} \cdot\frac{1}{2} = \frac{1}{12}$$

• if $k=\ell$, then $$\mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right] = \mathbb{E}\left[X_k^2 X_{k+1}^2 \right] = \mathbb{E}\left[X_k^2\right]\mathbb{E}\left[X_{k+1}^2\right] = \frac{1}{3}\cdot \frac{1}{3} = \frac{1}{9}$$

• if $k=\ell+1$, then $$\mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right] = \mathbb{E}\left[X_k^2 X_\ell X_{k+1} \right] = \mathbb{E}\left[X_k^2\right]\mathbb{E}\left[X_\ell\right]\mathbb{E}\left[ X_{k+1} \right] = \frac{1}{3}\cdot \frac{1}{2} \cdot\frac{1}{2} = \frac{1}{12}$$

• else, $$\mathbb{E}\left[X_kX_{k+1}X_\ell X_{\ell+1} \right] = \mathbb{E}\left[X_k\right]\mathbb{E}\left[ X_{k+1} \right]\mathbb{E}\left[X_\ell\right]\mathbb{E}\left[ X_{\ell+1} \right] = \frac{1}{16}$$

Overall, $$\mathbb{E} Z_n^2 = \sum_{k=1}^n \frac{1}{9} + 2\sum_{k=1}^{n-1} \frac{1}{12} + \sum_{k=1}^{n}\sum_{\ell=1}^{n} \frac{1}{16}\mathbf{1}_{|k-\ell|>1} = \frac{n}{9}+\frac{n-1}{6} + \frac{n^2-n-2(n-1)}{16} = \frac{9n^2+13n-6}{144}$$ and thus $$\operatorname{Var} Z_n = \mathbb{E} Z_n^2 - \mathbb{E}[ Z_n ]^2 = \frac{9n^2+13n-6}{144} - \frac{n^2}{16} = \boxed{\frac{13n-6}{144}}$$

As a sanity check, for $n=1$ we want the variance of $XX'$ where $X,X'$ are independent r.v.'s uniform in $[0,1]$; it is not hard to check that the variance in this case is $\frac{7}{144}$, matching the above result.