# Variance of Bernoulli Random Variable with a Random Variable as parameter

Let X be a Bernoulli Random Variable whose parameter is a Uniform Random Variable Q which takes values in the domain [0 , 0.1].

We want to find var(X). My reasoning is the following:

Using the Law of Total Variance we have:

var(X) = E[var(X|Q)] + var(E[X|Q]) = E[Q * (1 - Q)] + var(Q) = E[Q] - E[Q^2] + var(Q) = E[Q] - (var(Q) + (E[Q])^2) + var(Q) = E[Q] - (E[Q])^2 = 0.05 - 0.05^2 = 0.0475.

Do you agree with this line of reasoning?

• A Bernoulli random variable is either 0 with probability p or 1 with probability q=1-p. The possible value for the parameter belong to the interval [0,1] not [0, 0.1]. Its variance is p(1-p). – Michael R. Chernick Apr 19 '17 at 19:59
• Please note that the interval [0, 0.1] is a subset of the interval [0, 1] and therefore it is a legitimate domain for the parameter. In the particular problem the parameter is modeled --as I stated-- as a Random Variable uniformly distributed over the interval [0, 0.1]. E.g. assume a biased coin. You know that its bias is between 0 --never Heads-- and 0.1 --10% of the times Heads. Then you model the parameter as a Random Variable uniformly distributed in the interval [0, 0.1]. In dealing with a parameter that is a Random Variable you have to use the Law of Total Variance. – rf7 Apr 19 '17 at 21:12
• You are applying a distribution to an unknown fixed parameter. If you were doing Bayesian analysis this could make sense as a prior distribution. Then you would update when you observe a Bernoulli random outcome. – Michael R. Chernick Apr 19 '17 at 21:25
• If you are just want to know the variance of a uniform random variable on [0,0,1] there is no need to bring the Bernoulli variable into the picture. You can just integrate 10 (the density) time (x-0.05)$^2 dx to get the variance. – Michael R. Chernick Apr 19 '17 at 21:31 • Sorry, this was a typo. I want to find var(X) not var(Q) – rf7 Apr 19 '17 at 21:53 ## 1 Answer You are using the correct approach with the total variance law. $$\mathbb{V}ar(X)= \mathbb{V}ar(\mathbb{E}(X|Q)) + \mathbb{E}(\mathbb{V}ar(X|Q) ).$$ Here you will need the expectations and variances of the Bernoulli and the continuous uniform. These are: $$\mathbb{E}(X|Q)=Q,$$ $$\mathbb{V}ar(X|Q)=Q(1-Q),$$ $$\mathbb{E}(Q)=\frac{a+b}{2},$$ $$\mathbb{V}ar(Q)=\frac{(a-b)^2}{12},$$ where here$a=0.1$and$b=0.0\$, the limits of the continuous uniform. The only other thing I used to solve this was the variance relation

$$\mathbb{V}ar(Y) = \mathbb{E}(Y^2)-(\mathbb{E}(Y))^2.$$

This is rearranged to get a relationship between the mean and the variance to get the second moment if you know the mean and the variance. So from the total variance law

$$\mathbb{V}ar(X)= \mathbb{V}ar(\mathbb{E}(X|Q)) + \mathbb{E}(\mathbb{V}ar(X|Q) ) =\mathbb{V}ar(Q) + \mathbb{E}(Q(1-Q)) =\mathbb{V}ar(Q) + \mathbb{E}(Q)-\mathbb{E}(Q^2) =\frac{0.1^2}{12} + 0.05 - (\frac{.01^2}{12} + 0.05^2) =0.0008333333 + 0.05 - (0.000833333 + 0.0025) =0.05 - 0.0025 =0.0475$$ which matches what you have in the posting.