Take $U \sim \text{U}(0,1)$ as an underlying probability and generate $X_1,X_2,...,X_n \sim \text{Bern}(U)$ independent Bernoulli trials with this probability. The number of successes in the sample is:

$$S_n = \sum_{i=1}^n X_i.$$

How do I go about computing $\mathbb{E}(S_n)$ and $\mathbb{V}(S_n)$?

  • 4
    $\begingroup$ Welcome to CV. Since you’re new here, you may want to take our tour, which has information for new users. Since this looks like homework (apologies if it's not), please add the [self-study] tag and read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. If this is self-study rather than homework, let us know, and... it's still a good idea to show us what you've tried. $\endgroup$
    – jbowman
    Commented Mar 26, 2020 at 15:24
  • $\begingroup$ This has nothing to do with statistics. Please check the law of total expectation as a possible hint. $\endgroup$
    – Xi'an
    Commented Mar 26, 2020 at 15:35
  • $\begingroup$ @Xian is absolutely correct but it's also called the "iterated law of expectations" and the "tower property" in case you want to google for those. I'm only mentioning these terms because I was not familiar with the term "total expectations" so maybe the other terms are more popular ? I don't know but it's good to know all the terms if you're going to go googling. $\endgroup$
    – mlofton
    Commented Mar 26, 2020 at 18:34

1 Answer 1


This is a problem where you have information about the conditional distribution of a random variable, and the distribution of the underlying conditioning variable, and you need to use this to obtain the marginal moments of that random variable. To start you off, since your sample values are Bernoulli random variables, their sum follows a binomial distribution:

$$\mathbb{P}(S_n=s|U=u) = \text{Bin}(s|n, u).$$

Thus, the conditional mean and variance of the sample sum are:

$$\mathbb{E}(S_n|U=u) = nu \quad \quad \quad \mathbb{V}(S_n|U=u) = nu(1-u).$$

To obtain the marginal mean and variance (i.e., not conditioning on $U$) you will need to obtain the moments of the underlying conditioning random variable $u$, and then you can apply the law of iterated expectation and the law of iterated variance. Give this a go and see what answers you get.

  • $\begingroup$ Oh! I have figured it out :) Thank you so much for the guidance! $\endgroup$
    – user277763
    Commented Mar 30, 2020 at 13:19

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.