# -*- coding: utf-8 -*-
"""poisson-distribution-and-poisson-process-tutorial.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1u-t6oSxbMd2FrzaIMimXnPMR5dfV6Gel

# Diving Into the Poisson Distribution and Poisson Process

* Tutorial: https://news.towardsai.net/pd
* Github: https://github.com/towardsai/tutorials/tree/master/poisson-distribution-process

A TV Assembly unit performs a defects analysis task to understand the number of defects that could happen for a given defective TV. Using past quality and audit data is noted that 12 defects are marked on an average for a defective TV, calculate below:

* The probability that a defective laptop has exactly 5 defects.
* The probability that a defective laptop has less than 5 defects.
"""

import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt

n = np.arange(0,30)
n

rate = 12
poisson = stats.poisson.pmf(n,rate)

poisson

poisson[5]

poisson[0] + poisson[1] + poisson[2] + poisson[3] + poisson[4]

plt.plot(n,poisson, 'o-')
plt.show()