Statistical Distribution

  • Discrete distribution
  • Contious distribution
  • Sample(small) distribution

Discrete Distribution

  • Binomial distribution $B(n,p)$
  • Hypergeometric distribution
  • Geometric distribution
  • Poisson distribution $P(\lambda)$

1.1 Binomial distribution $B(n,p)$

$$ P(X=k) = C_n^k p^k (1-p)^{n-k}, k=0,1,...,n$$

then $ X \sim B(n,p) $.


In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

n,p=50,0.1

plt.hist(np.random.binomial(n,p,size=5000))
plt.show()


1.2 Hypergeometric distribution

$$ P(X=k) = \frac {C_M^k C_{N-M}^{n-k}} {C_N^n} $$

then $ X \sim$ Hypergeometric distribution with parameters $\{N,M,n\}$


In [2]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

ngood, nbad, nsamp = 90, 10, 50

plt.hist(np.random.hypergeometric(ngood, nbad, nsamp, 5000))
plt.show()


1.3 Geometric distribution

$$ P(X=k) = p(1-p)^{k-1}$$

In [3]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.geometric(p=0.35, size=10000))
plt.show()


1.4 Poisson distribution $P(\lambda)$

$$ P(X=k) = e^{-\lambda} \frac{\lambda^k}{k!}, k = 0,1,2,... $$

then $ X \sim P(\lambda)$, $\lambda>0$


In [4]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.poisson(5, 10000))
plt.show()


Contious distribution

  • Homogeneous distribution $R(a,b)$
  • Exponential distribution $E(\lambda)$
  • Normal distribution $N(\mu,\sigma^2)$

2.1 Homogeneous distribution $R(a,b)$

$$ f(x)=\left\{\begin{array}{ll} c, & a<x<b \\ 0, & otherwise \end{array}\right.$$

then $X \sim R(a,b)$


In [5]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.random_sample(1000))
plt.show()


2.2 Exponential distribution $E(\lambda)$

$$ f(x)=\left\{\begin{array}{ll} \lambda e^{-\lambda x}, & x>0 \\ 0, & otherwise \end{array}\right.$$

then $X \sim E(\lambda)$


In [6]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.exponential(scale=1.0, size=1000))
plt.show()


2.3 Normal distribution $N(\mu,\sigma^2)$

$$ f(x) = \frac {1} {\sqrt{2\pi\sigma}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$

then $X \sim N(\mu,\sigma^2)$.


In [7]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.normal(size=4000))
plt.show()


Sample(small) distribution

  • $\chi^2$ distribution $\chi^2(n)$
  • t distribution $t(n)$
  • F distribution $F(n)$

3.1 $\chi^2$ distribution $\chi^2(n)$

Given $X_i \sim N(0,1)$, $$ Y = \sum_{i=1}^{N} X_i^2 \sim \chi^2(n) $$


In [8]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.chisquare(3,1000))
plt.show()


3.2 t distribution $t(n)$

Given $X \sim N(0,1)$, $Y \sim \chi^2(n)$, $$ T \hat{=} \frac{X}{\sqrt{\frac{Y}{n}}} \sim t(n)$$


In [9]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.standard_t(2,50))
plt.show()


3.3 F distribution $F(n)$

Given $X \sim \chi^2(m)$, $Y \sim \chi^2(n)$, $$ F \hat{=} \frac{\frac{X}{m}}{\frac{Y}{n}} \sim F(m,n)$$


In [10]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(np.random.f(4,10,5000))
plt.show()



In [ ]: