> For the complete documentation index, see [llms.txt](https://stephanosterburg.gitbook.io/scrapbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stephanosterburg.gitbook.io/scrapbook/math/statistics-and-probability/binomial-variables.md).

# Binomial variables

coin flip -> P(H) = 0.6; P(T) = 0.4

X = # of heads after 10 flips of my coin

* made up of independent trails (flip)
* each trail can be classified either as success or failure
* fixed # of trails
* probability of success on each trail is constant

Inference -> The act or process of deriving logical conclusions from premises known or assumed to be true.

### Distribution

X = # of heads from flipping a coin 5 times

possible outcomes from 5 flips: $$2 \* 2 \* 2 \* 2 \* 2 = 2^5 = 32$$

$$P(X=0) = \frac{1}{32} =\frac{\_5 C\_0}{32} \Rightarrow \_5 C\_0 = \frac{5!}{0! \* (5-0)!} = \frac{5!}{5!} = 1$$

$$P(X=1) = \frac{5}{32} = \frac{\_5 C\_1}{32} \Rightarrow \_5C\_1 = \frac{5!}{1!\*(5-1)!}=\frac{5!}{1!}=5$$

$$P(X=2) = \frac{10}{32} = \frac{\_5 C\_2}{32} \Rightarrow \_5C\_2 = \frac{5!}{2!*(5-2)!}=\frac{5!}{2!*3!}=\frac{5*4*3*2}{2*3\*2}=10$$

$$P(X=3) = \frac{10}{32} = \frac{\_5 C\_3}{32} \Rightarrow \_5C\_3 = \frac{5!}{3!\*(5-3)!}=\frac{5!}{3!\*2!}=10$$

$$P(X=4) = \frac{5}{32} = \frac{\_5 C\_4}{32} \Rightarrow \_5C\_4 = \frac{5!}{4!\*(5-4)!}=\frac{5!}{1!}=5$$

$$P(X=5) = \frac{1}{32} =\frac{\_5 C\_5}{32} \Rightarrow \_5 C\_5 = \frac{5!}{5! \* (5-5)!} = \frac{5!}{5!} = 1$$

### Example:

prob (score) = 70% or 0.7

prob (miss) = 30% or 0.3

**P(Exactly 2 scores in 6 attempts) =**&#x20;

$$\binom {6}{2} \* 0.7^2 \* 0.3^4 = 15 \* 0.49 \* 0.0081 = 0.05935$$

$$\Longrightarrow \text{SSMMMM} = 0.7 \* 0.7 \* 0.3 \* 0.3 \* 0.3 \* 0.3 = (0.7)^2 \* (0.3)^4$$

$$\Longrightarrow  \_6C\_2 = \binom{6}{2}=\frac{6!}{2!*(6-2)!} = \frac{6*5*4*3*2*1}{(2*1(4*3*2*1)}=15$$

### Generalizing k scores in n attempts:

&#x20;**P(Exactly** $$k$$ **scores in** $$n$$ **attempts) =** $$\large\binom{n}{k}\* f^k \* (1-f)^{n-k}$$

f = prob of making attempts

#### A binomial probability problem has these features:

* a set number of trials ($$\blueD{n}$$)
* each trial can be classified as a "success" or "failure"
* the probability of success ($$\greenD{p}$$) is the same for each trial
* results from each trial are independent from each other

Here's a summary of our general strategy for binomial probability:

![](/files/-LN9uYXz7Q_ku8IqZH5W)

Using the example from Problem 1:

* $$n=3$$ free-throws
* each free-throw is a "make" (success) or a "miss" (failure)
* probability she makes a free-throw is $$\greenD{p}=\greenD{0.90}$$
* assume free-throws are independent

$$\begin{aligned}P(\text{makes 2 of 3 free throws}) &= , \_3\text{C}\_2 \cdot(\greenD{0.90})^{2} \cdot (\maroonD{0.10})^1 \ \ &=3\cdot0.81\cdot0.10 \ \ &=3\cdot0.081 \ \ &=0.243\end{aligned}$$

**In general...**

$$P(\text{exactly }k \text{ successes})=,\_n\text{C}\_k \cdot p^k \cdot (1-p)^{n-k}$$

### **Challenge Problem**

Steph promises to buy Luke ice cream if he makes $$3$$ or more of his $$4$$ free-throws.

**What is the probability that he makes** $$3$$ **or more of the** $$4$$ **free throws?**

Luke gets ice cream if he makes $$3$$ or $$4$$ free throws. We can find the probability of each of those outcomes and add the results together.Here's how we can think of this problem:

* $$n=4$$ trials (shots)
* each shot is either a make or miss
* probability that he makes a shot is $$p=0.20$$
* shots are independent

$$\begin{aligned}P(\text{makes 3 or more}) &= P(\text{makes 3 free-throws}) + P(\text{makes 4 free-throws}) \ \ & =,\_4\text{C}\_3 \cdot (0.20)^3 \cdot (0.80)^1+,\_4\text{C}\_4 \cdot (0.20)^4 \cdot (0.80)^0 \ \ &= \dfrac{4!}{(4-3)! \cdot3!} \cdot0.008 \cdot 0.80+\dfrac{4!}{(4-4)! \cdot4!} \cdot 0.0016 \ \ &=\dfrac{4 \cdot 3\cdot 2\cdot 1}{3\cdot 2 \cdot 1}\cdot0.008 \cdot 0.80 +\dfrac{4 \cdot 3\cdot 2\cdot 1}{4 \cdot 3 \cdot 2 \cdot 1} \cdot0.0016 \ \ &=4 \cdot0.008 \cdot 0.80+0.0016\ \ &=0.0256+0.0016 \ \ &=0.0272\end{aligned}$$<br>

### Quiz #1

Layla has a coin that has a $$60%$$ chance of showing heads each time it is flipped. She is going to flip the coin $$5$$ times. Let $$X$$ represent the number of heads she gets.

**What is the probability that she gets more than** $$3$$ **heads?**

#### Finding $$P(X=5)$$

For each flip, we know $$P(\blueD{\text{heads}})=\blueD{60%}$$. To find the probability that all $$5$$ flips are heads, we can multiply probabilities since flips are independent:

$$\begin{aligned} P(X=5)&=(\blueD{0.60})(\blueD{0.60})(\blueD{0.60})(\blueD{0.60})(\blueD{0.60}) \\\ &=(\blueD{0.60})^5 \\\ &=0.07776 \end{aligned}$$

We'll come back and use this result later. Next, we need to find $$P(X=4)$$ (the probability that she gets $$4$$ heads).

#### Finding $$P(X=4)$$

Getting $$4$$ heads in $$5$$ attempts means Layla needs to get $$4$$ heads and $$1$$ tail. For each flip, we know $$P(\blueD{\text{heads}})=\blueD{60%}$$ and $$P(\maroonD{\text{tails}})=\maroonD{40%}$$.

Let's start by finding the probability of getting $$4$$ heads followed by $$1$$ tail:

$$P(\blueD{\text{HHHH}}\maroonD{\text{T}})=(\blueD{0.6})^4(\maroonD{0.4})=0.05184$$

This isn't the entire probability though, because there are other ways to get $$4$$ heads from $$5$$ flips (for example, THHHH). How many different ways are there? We can use the combination formula:

$$\begin{aligned} \_n\text{C}\_k&=\dfrac{n!}{(n-k)!\cdot k!} \\\ \_5\text{C}\_4&=\dfrac{5!}{(5-4)!\cdot4!} \\\ &=\dfrac{5 \cdot \cancel{4 \cdot 3 \cdot 2 \cdot 1}}{(1) \cdot \cancel{4 \cdot 3 \cdot 2 \cdot 1}} \\\ &=5 \end{aligned}$$

&#x20;Do they all have the same probability?

Each of the $$5$$ ways has the same probability that we already found:

$$\begin{aligned} P(\blueD{\text{HHHH}}\maroonD{\text{T}})&=(\blueD{0.6})^4(\maroonD{0.4})=0.05184 \\\ P(\blueD{\text{HHH}}\maroonD{\text{T}}\blueD{\text{H}})&=(\blueD{0.6})^4(\maroonD{0.4})=0.05184 \\\ P(\blueD{\text{HH}}\maroonD{\text{T}}\blueD{\text{HH}})&=(\blueD{0.6})^4(\maroonD{0.4})=0.05184 \\\ P(\blueD{\text{H}}\maroonD{\text{T}}\blueD{\text{HHH}})&=(\blueD{0.6})^4(\maroonD{0.4})=0.05184 \\\ P(\maroonD{\text{T}}\blueD{\text{HHHH}})&=(\blueD{0.6})^4(\maroonD{0.4})=0.05184 \end{aligned}$$

So we can multiply this probability by $$5$$ since that is how many ways there are to get $$4$$ heads in $$5$$ flips.

$$\begin{aligned} P(X=4)&=5(0.6)^4(0.4) \\\ &=5(0.05184) \\\ &=0.2592 \end{aligned}$$

#### Putting it all together

Let's return to our original strategy to answer the question:

$$\begin{aligned} P(X>3)&=P(4\text{ heads})+P(5\text{ heads}) \\\ &=P(X=4)+P(X=5) \\\ &=5(0.6)^4(0.4)+(0.6)^5 \\\ &=0.2592+0.07776 \\\ &=0.33696 \\\ &\approx0.34 \end{aligned}$$<br>

### Quiz #2

Ira ran out of time while taking a multiple-choice test and plans to guess on the last $$6$$ questions. Each question has $$4$$ possible choices, one of which is correct. Let $$X=$$ the number of answers Ira correctly guesses in the last $$6$$ questions.

**What is the probability that he answers fewer than** $$2$$ **questions correctly in the last** $$6$$ **questions?**

#### Strategy (without a fancy calculator)

The probability that Ira gets fewer than $$2$$ questions correct in the $$6$$ questions is equivalent to the probability that he gets $$0$$ or $$1$$ question correct. So we can find those probabilities and add them them together to get our answer:

$$\begin{aligned} P(X<2)&=P(0\text{ correct})+P(1\text{ correct}) \\\ &=P(X=0)+P(X=1) \end{aligned}$$<br>

#### Finding $$P(X=0)$$

There are $$4$$ possible choices for each question, so we know $$P(\blueD{\text{correct}})=\blueD{25%}$$ and $$P(\maroonD{\text{not}})=\maroonD{75%}$$. Answering $$0$$ questions correctly is equivalent to answering all $$6$$ questions incorrectly. We can multiply probabilities since we are assuming independence:

$$\begin{aligned} P(X=0)&=(\maroonD{0.75})(\maroonD{0.75})(\maroonD{0.75})(\maroonD{0.75})(\maroonD{0.75})(\maroonD{0.75}) \\\ &=(\maroonD{0.75})^6 \\\ &\approx0.17798 \end{aligned}$$

​We'll come back and use this result later. Next, we need to find $$P(X=1)$$ (the probability that he answers $$1$$ question correctly).

#### Finding $$P(X=1)$$

Answering $$1$$ question correctly in the last $$6$$ questions means Ira needs to get $$1$$ question correct and $$5$$ questions not correct. There are $$4$$ possible choices for each question, so we know $$P(\blueD{\text{correct}})=\blueD{25%}$$ and $$P(\maroonD{\text{not}})=\maroonD{75%}$$.&#x20;

Since we are assuming independence, let's multiply probabilities to find the probability of getting $$1$$ question correct followed by $$5$$ questions not correct:

$$P(\blueD{\text{C}}\maroonD{\text{NNNNN}})=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933$$

This isn't the entire probability though, because there are other ways to get $$1$$ question correct from $$6$$ questions (for example, NNNNNC). How many different ways are there? We can use the combination formula:

$$\begin{aligned} \_n\text{C}\_k&=\dfrac{n!}{(n-k)!\cdot k!} \\\ \_6\text{C}\_1&=\dfrac{6!}{(6-1)!\cdot1!} \\\ &=\dfrac{6 \cdot \cancel{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}}{(\cancel{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}) \cdot 1} \\\ &=6 \end{aligned}$$

There are $$6$$ ways to get $$1$$ question correct in $$6$$ questions. Do they all have the same probability?

Each of the $$6$$ ways has the same probability that we already found:

$$\begin{aligned} P(\blueD{\text{C}}\maroonD{\text{NNNNN}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \\\ P(\maroonD{\text{N}}\blueD{\text{C}}\maroonD{\text{NNNN}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \\\ P(\maroonD{\text{NN}}\blueD{\text{C}}\maroonD{\text{NNN}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \\\ P(\maroonD{\text{NNN}}\blueD{\text{C}}\maroonD{\text{NN}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \\\ P(\maroonD{\text{NNNN}}\blueD{\text{C}}\maroonD{\text{N}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \\\ P(\maroonD{\text{NNNNN}}\blueD{\text{C}})&=(\blueD{0.25})(\maroonD{0.75})^5\approx0.05933 \end{aligned}$$

​So we can multiply this probability by $$6$$ since that is how many ways there are to get $$1$$ question correct in $$6$$ questions:

$$\begin{aligned} P(X=1)&=6(0.25)(0.75)^5 \\\ &\approx6(0.05933) \\\ &\approx0.35596 \end{aligned}$$​<br>

#### Putting it all together

Let's return to our original strategy to answer the question:

$$\begin{aligned} P(X<2)&=P(0\text{ correct})+P(1\text{ correct}) \\\ &=P(X=0)+P(X=1) \\\ &=(0.75)^6+6(0.25)(0.75)^5 \\\ &\approx0.17798+0.35596 \\\ &\approx0.53394 \\\ &\approx0.53 \end{aligned}$$<br>
