A $\textbf {Binomial Distribution}$ can be thought of as simply the probability of a SUCCESS or FAILURE outcome in an experiment or survey that is repeated multiple times. The binomial is a type of distribution that has two possible outcomes (the prefix “bi” means two, or twice). 

$\textbf {For example,}$ a coin toss has only two possible outcomes: heads or tails and taking a test could have two possible outcomes: pass or fail.<br>
The Probability Density Function (PDF) for $\textbf {Binomial Distribution}$ is defined as::<br>
\begin{equation} 
P(X=K) = {N\choose K}{p}^K{q}^N-K 
\end{equation}
<br>
$\textbf {Coin Tossing Example:}$

If we toss a coin 5 times and find the probability of getting a 1 head.
The following events can happen are:
<ul>
    <li> H,T,T,T,T</li>
    <li> T,H,T,T,T</li>
    <li> T,T,H,T,T</li>
    <li> T,T,T,H,T</li>
    <li> T,T,T,T,H</li>
</ul>

$Probability(P) = P(H{\cap T \cap T \cap T \cap T})$
<br>
We also know that coin tossing is a independent probability and it will not affect each other's probability.So, each probabilities will be multiplied.
<br>
$Probability(P) = P(H).P(T).P(T).P(T).P(T)$
<br>

Let's assume a coin is tossed for 25 crores times and Head (H) comes for 65% times. <br>
Probability of getting Head = P(H) = p (Success of getting Head) = 0.65 <br>
Probability of getting Tail = P(T) = q (Failure of getting Head or Success of getting Tail) 
                                   = 1-p = 0.35
<br>
    
<B>Conditions for Binomial Random Variable:</B><br>
<ol>
    <li> The outcomes of the random variable should be 2. </li>
    <li> They should an independent event </li>
</ol>


```python
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as S
```


```python
p = 0.5
N = 10
q = 1-p
```


```python
RandomValues = np.arange(0,N+1)
```


```python
RandomValues
```




    array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10])




```python
BinomialValuesPDF = S.binom.pmf(RandomValues,N,p)
```


```python
BinomialValuesPDF
```




    array([0.00097656, 0.00976563, 0.04394531, 0.1171875 , 0.20507813,
           0.24609375, 0.20507813, 0.1171875 , 0.04394531, 0.00976563,
           0.00097656])




```python
plt.stem(RandomValues,BinomialValuesPDF)
```

The skewness at the x-axis of the graph will be dependent on the values of the p (Success) and q(Failure).<br>
<ul>
    <li> If <b>p is greater than q</b> the skewness towards <b>Right side </b></li>
    <li> If <b>p is less than q</b> the skewness towards <b>Left side </b></li>
</ul>
Let's see this by this example.


```python
p = 0.7
N = 10
q = 1-p
```


```python
RandomValues = np.arange(0,N+1)
```


```python
BinomialValuesPDF = S.binom.pmf(RandomValues,N,p)
```


```python
plt.stem(RandomValues,BinomialValuesPDF)
```


```python
p = 0.3
N = 10
q = 1-p
```


```python
RandomValues = np.arange(0,N+1)
```


```python
BinomialValuesPDF = S.binom.pmf(RandomValues,N,p)
```


```python
plt.stem(RandomValues,BinomialValuesPDF)
```

The mean of the binomial distribution is: 
$ E[X]=Np $<br>
The Variance of the binomial distribution is : $ E[(X-E[X]^2)] = Npq $ <br>
The Standard deviation of the binomial distribution is : $\sqrt {Npq} $


```python

```

18a27e4837abe4f476929614c73131a1cc933cd1
ipynb
Jupyter Notebook
3. Binomial Distribution.ipynb
rarpit1994/Probability-and-Statistics
1ae8b7428ec9a3072fce3089d7951b9f7bd06c26
Apache-2.0
2019-03-24T10:29:56.000Z
2019-03-24T10:29:56.000Z
3. Binomial Distribution.ipynb
rarpit1994/Probability-and-Statistics
1ae8b7428ec9a3072fce3089d7951b9f7bd06c26
Apache-2.0
3. Binomial Distribution.ipynb
rarpit1994/Probability-and-Statistics
1ae8b7428ec9a3072fce3089d7951b9f7bd06c26
Apache-2.0
Qwen/Qwen-72B
1. YES
2. YES