Probability - binomial distribution

47 Views Asked by At

I started to learn probability, and thinking there's maybe a simpler way to calculate this than I did:

The probability for someone to be sick is 0.4. If I chose 10 people, and X is the number of people that is sick. I need to calculate X≤5.

I thought to do it with the binomial equation: ${\displaystyle P\left(X=k\right)={n \choose k}p^{k}\left(1-p\right)^{n-k}}$

To chose zero from 10 and then 1 from 10 etc till I get to 5, and then to sum all the probabilities.

so...is there another way?

1

There are 1 best solutions below

0
On

You can arrange this calculation in Horner form. There is more overhead, but fewer multiplications and no factorials/binomials. Let us explain this method with your example.

You evaluated \begin{align*} S &= \sum_{k=0}^5 \binom{n}{k} p^k (1-p)^{n-k} \\ & = (1-p)^n \\ &\quad + \frac{n}{1} \frac{p}{1-p} (1-p)^n \\ &\quad + \frac{n-1}{2}\frac{n}{1} \left(\frac{p}{1-p}\right)^2 (1-p)^n \\ &\quad + \frac{n-2}{3}\frac{n-1}{2}\frac{n}{1} \left(\frac{p}{1-p}\right)^3 (1-p)^n \\ &\quad + \frac{n-3}{4}\frac{n-2}{3}\frac{n-1}{2}\frac{n}{1} \left(\frac{p}{1-p}\right)^4 (1-p)^n \\ &\quad + \frac{n-4}{5}\frac{n-3}{4}\frac{n-2}{3}\frac{n-1}{2}\frac{n}{1} \left(\frac{p}{1-p}\right)^5 (1-p)^n \text{.} \end{align*} Notice that each term divides all the subsequent terms, so \begin{align*} S &= (1-p)^n\left(1 + \phantom{\frac{1}{1}} \right. \\ &\quad \frac{n}{1} \frac{p}{p-1} \left(1 + \phantom{\frac{1}{1}} \right. \\ &\quad\quad \frac{n-1}{2} \frac{p}{p-1} \left(1 + \phantom{\frac{1}{1}} \right. \\ &\quad\quad\quad \frac{n-2}{3} \frac{p}{p-1} \left(1 + \phantom{\frac{1}{1}} \right. \\ &\quad\quad\quad\quad \frac{n-3}{4} \frac{p}{p-1} \left(1 + \phantom{\frac{1}{1}} \right. \\ &\quad\quad\quad\quad\quad \left.\left.\left.\left.\left. \frac{n-4}{5} \frac{p}{p-1} \right)\right)\right)\right)\right) \\ \end{align*} Then, what has this bought us?

(* n is a given nonnegative integer  *)
(* p is a given rational or real in [0,1] *)
k := 5  (*  0 <= k <= n  *)
term := (n-(k-1))/k*p/(1-p)
accum := 1
while k >= 0
    accum := 1 + term*accum
    k := k - 1
    term := term * ((n-k+1)*(k+1))/((n-k)*k)
print (1-p)^n * accum

The only somewhat awkward expression, ((n-k+1)*(k+1))/((n-k)*k) is familiar to those old enough to compute these sums mentally or with a non-scientific calculator. It is easier than it looks. For instance, when $k =2$, this is "($n$ minus $1$) times $3$; and divide that by (($n$ minus $2$) times $2$)". (This term, in the nested expression above, chops off the previous leading fraction and inserts the new leading fraction -- it helps to notice the numerators are increasing, "$n$ minus $1$" bigger than "$n$ minus $2$", and the denominators are decreasing, "times $2$" less than "times $3$".) It only takes a little practice to do this quickly on a non-scientific calculator.