# Binomial distribution with random parameter uniformly distributed

I have a problem with the following exercise from Geoffrey G. Grimmett, David R. Stirzaker, Probability and Random Processes, Oxford University Press 2001 (page 155, ex. 6):

Let $$X$$ have the binomial distribution bin($$n$$, $$U$$), where $$U$$ is uniform on $$(0,1)$$. Show that $$X$$ is uniformly distributed on $$\{0,1,\ldots,n\}$$.

So far, what I have is this: $$P(X=k | U) = {n \choose k} U^k (1-U)^{n-k}$$ $$P(X=k) = \int_0^1 {n \choose k} u^k (1-u)^{n-k} f_U(u) \text{ d}u$$

where $$f_U(u)$$ is density function of random variable $$X$$. Of course, $$f_U(u) = 1$$ on $$u\in (0,1)$$.

$$P(X=k) = {n \choose k} \int_0^1 u^k (1-u)^{n-k} \text{d}u$$ And I don't know what to do next... How to calculate this integral? Am I solving it right so far?

• For the record, and to make this easier to find for future generations: this is a so-called compound distribution, which is confusingly also known as a mixture distribution. Jun 17, 2020 at 12:40

A way to avoid using pre-knowledge about Beta integrals (for a more conceptual explanation, see the second part of this post) is to compute the generating function of $X$, that is, $$\mathbb E(s^X)=\sum_{k=0}^ns^k\mathbb P(X=k)=\int_0^1\sum_{k=0}^n\binom{n}ku^k(1-u)^{n-k}s^k\mathrm du.$$ By the binomial theorem, $$\sum_{k=0}^n\binom{n}k(su)^k(1-u)^{n-k}=(1-(1-s)u)^n,$$ hence $$\mathbb E(s^X)=\int_0^1(1-(1-s)u)^n\mathrm du\stackrel{[v=1-(1-s)u]}{=}\frac1{1-s}\int_s^1v^n\mathrm dv=\frac{1-s^{n+1}}{(n+1)(1-s)},$$ that is, $$\mathbb E(s^X)=\frac1{n+1}\sum_{k=0}^ns^k.$$ This formula should make apparent the fact that $X$ is uniform on $\{0,1,2,\ldots,n\}$...

...But the "real" reason why $X$ is uniform might be the following.

First, the distribution of a sum of i.i.d. Bernoulli random variables is binomial. Second, if $V$ is uniform on $[0,1]$, the random variable $\mathbf 1_{V\leqslant u}$ is Bernoulli with parameter $u$. Hence, if $(U_i)_{1\leqslant i\leqslant n}$ is i.i.d. uniform on $[0,1]$, the random variable $\sum\limits_{i=1}^n\mathbf 1_{U_i\leqslant u}$ is binomial with parameter $(n,u)$.

Thus, $X$ may be realized as $X=\sum\limits_{i=1}^n\mathbf 1_{U_i\leqslant U_{n+1}}$ where $(U_i)_{1\leqslant i\leqslant n+1}$ is i.i.d. uniform on $[0,1]$. The event $[X=k]$ occurs when $U_{n+1}$ is the $(k+1)$th value in the ordered sample $(U_{(i)})_{1\leqslant i\leqslant n+1}$. By exchangeability of the distribution of $(U_i)_{1\leqslant i\leqslant n+1}$, $U_{n+1}$ has as much chances to be at each rank from $1$ to $n+1$. This fact means exactly that $X$ is indeed uniform on $\{0,1,2,\ldots,n\}$.

• That's a cool solution!
– Alex
Jan 19, 2013 at 23:53
• The limits for your integration after the variable substitution don't totally make sense to me. if $v=1-(1-s)u$, then since the original lower limit was $u=0$, then plugging that in gives $v=1$ for the lower limit and since the original upper limit was $u=1$, then plugging that in gives $v=s$ for the upper limit, right? Nov 5, 2018 at 1:01
• @Hunle Except that $s<1$ hence $1$ is the upper limit, not the lower one, and $s$ is the lower limit, not the upper one.
– Did
Nov 5, 2018 at 7:19

The integral $$\int_0^1 x^\alpha (1 - x)^\beta dx$$ has a well-know representation in terms of $\Gamma$ functions. In the integer case, it boils down to factorials.

Hint: Integrating by parts:

$$\int_0^1 u^k (1-u)^{n-k} \text{d}u = \frac{n-k}{k+1}\int_0^1 u^{k+1} (1-u)^{n-k-1} du$$
so repeat until the exponent of $(1-u)$ reduces to $0$ and you have $$\frac{1}{n \choose k} \int_0^1 u^{n} \text{d}u$$