# Distribution

### **Negative Binomial Distribution**

***Binomial Distribution***: "I flip a fair coin 5 times. What are the chances that I get heads 0 times? 1 time? 2 times? Etc..."

***Negative Binomial Distribution***: I flip a fair coin 5 times. What are the chances it takes me two flips to get heads twice? How about 3 flips to get heads twice? 4 Flips? Etc..."

#### Characteristics of the Negative Binomial Distribution <a href="#characteristics-of-the-negative-binomial-distribution" id="characteristics-of-the-negative-binomial-distribution"></a>

The ***mean*** of the Negative Binomial Distribution is:

$$\large \mu = \frac{r}{p}$$

The ***variance*** of the Negative Binomial Distribution is:

$$\large \sigma^2 = \frac{r(1-p)}{p^2}$$

```
import numpy as np

s = np.random.negative_binomial(2, 0.5, 100000)
for i in range(1, 11):
    probability = sum(s<i) / 1000000
    print("{} coins flipped, probability of success: {:.4f}%".format(i, probability * 100))
```

### **Geometric and Negative Binomial Distributions**

The Geometric Distribution is a discrete probability distribution that helps us calculate the probability distribution of repeated independent events.

### Poisson Distribution

The ***Poisson Distribution*** lets us ask how likely any given number of events are over a set interval of time.

#### Sample Question 1[¶](https://fra-08-54396.ide-proxy.ide.learn.co/notebooks/dsc-2-19-07-poisson-distribution-online-ds-ft-100118/index.ipynb#Sample-Question-1) <a href="#sample-question-1" id="sample-question-1"></a>

An average of 20 customers walk into a store in a given hour. What is the probability that 25 customers walks into a store in the next hour?

#### Sample Question 2 <a href="#sample-question-2" id="sample-question-2"></a>

A police officer pulls over an average of 3 people for speeding violations per shift. What is the probability that the officer will pull over two people for speeding violations during their next shift?

### Exponential Distribution

The ***Exponential Distribution*** describes the probability distribution of the amount of time it may take before an event occurs. In a way, it solves the inverse of the problem solves by the Poisson Distribution.

The ***Exponential Distribution*** lets us ask how likely the *length of an interval of time* is before an event occurs exactly once.

### Sampling
