# Problem on Bernoulli trial

Prove that in $n$ Bernoulli trials with probability of failure $q$, the probability of at most $k$ successes is $$\frac{\int_0^q{x^{n-k-1}(1-x)^k}dx}{\int_0^1{x^{n-k-1}(1-x)^k}dx}.$$

Attempt

At most $k$ success in $n$ trial = $$P(X \leq k)=P(X=0)+P(X=1)+\dots +P(X=k)=\sum_{i=0}^kq^{n-i}p^i$$

I don't understand how to solve and where I am wrong.

• I'm not sure quite what you're asking; is there an error with the formatting in those integrals? Are they supposed to be multiplied? Also, are we assuming the trials are independent? – Math1000 Mar 12 '15 at 17:09
• @Math1000 Question is correct. They are multiplied. – user1942348 Mar 12 '15 at 17:13
• The integral is related to the incomplete Beta function. See fr.wikipedia.org/wiki/… (the French article is more complete) – Yves Daoust Mar 12 '15 at 17:30
• @YvesDaoust I don't know French also I am unable to understand the steps. Would you please write in more details in english. – user1942348 Mar 12 '15 at 17:36
• @Math1000 The multiplication will be replaced by division. I just checked the recent edition of the book online and I have changed my question accordingly. – user1942348 Mar 12 '15 at 17:51

If $X_j$ are iid $\operatorname{Ber}(p)$ (here I use $p$ as the probability of success, so $p=1-q$) random variables, then $$S_n=\sum_{j=1}^n X_j$$ has $\operatorname{Bin}(n,p)$ distribution, as can be verified by induction. So for $0\leqslant k\leqslant n$, $$\mathbb P(S_n\leqslant k)=\sum_{j=0}^k \mathbb P(S_n=j)=\sum_{j=0}^k \binom kj p^j (1-p)^{k-j}.$$ To find the distribution of $S_n$, clearly $S_1$ has $\operatorname{Bin}(1,p)$ distribution (the same as $\operatorname{Ber}(p)$). Now if $S_n\sim\operatorname{Bin}(n,p)$ for some $n\geqslant 1$, then for $0\leqslant j\leqslant n+1$, \begin{align*} \mathbb P(S_{n+1} = j) &= \mathbb P(S_n + X_{n+1} = j)\\ &= \mathbb P(S_n+X_{n+1}=j, X_{n+1}=0) + \mathbb P(S_n+X_{n+1}=j,X_{n+1}=1)\\ &= \mathbb P(S_n+X_{n+1}=j|X_{n+1}=0)\mathbb P(X_{n+1}=0) + \mathbb P(S_n+X_{n+1}=j|X_{n+1}=1)\mathbb P(X_{n+1}=1)\\ &= \mathbb P(S_n=j)\mathbb P(X_{n+1}=0) +\mathbb P(S_n=j-1)\mathbb P(X_{n+1}=1)\\ &= \binom nj p^j(1-p)^{n-j}(1-p) + \binom n{j-1} p^{j-1}(1-p)^{n-(j-1)}p\\ &= \binom nj p^j(1-p)^{n-j+1} + \binom n{j-1}p^j(1-p)^{n-j+1}\\ &= \left( \binom nj + \binom n{j-1} \right) (p^j(1-p)^{n-j+1})\\ &= \binom{n+1}j p^j(1-p)^{n+1-j}, \end{align*} so that $S_{n+1}\sim\operatorname{Bin}(n+1,p)$. As far as your original question is concerned, let $$B(y;a,b) = \int_0^y x^{a-1}(1-x)^{b-1}\mathsf dx$$ for $y\in(0,1)$. This is the incomplete beta function. The regularized incomplete beta function, with $y=1-p$, $a=n-k$, $b=k+1$ would be $$I_{1-p}(n-k,k+1) = \frac{\int_0^{1-p}x^{n-k-1}(1-x)^k\mathsf dx}{\int_0^1x^{n-k-1}(1-x)^k\mathsf dx},$$ which from the Wikipedia article is equal to the probability computed above. As for a proof of that fact, I will have to defer to someone more knowledgeable...