2.7 Probability Distributions

A function that assigns probabilities to outcomes, defining the overall behavior of a random process. 🤓

Bernoulli Distribution

\[ p_{X}(x) = \begin{cases} p & \text{if } x = 1, \\ q = 1-p & \text{if } x = 0. \end{cases} \]

  • The discrete random variable can take value \(1\) with probability \(p\) or value \(0\) with probability \(q = 1 - p\)
  • Not to be confused with the binomial distribution, since only one trial is being conducted.
  • \(\mathbb{E}[X] = p\)
  • \(Var[X] = pq\)

Python Code: Bernoulli Distribution

To create Bernoulli distributed data using numpy:

import numpy as np

interval = [0,1]
size = (1000,1)
p = [1-0.5, 0.5]

data = np.random.choice(interval, size, p = p)

Gaussian Distribution

\[ f_{X}(x)=\frac{1}{\sqrt{2\pi\sigma^{2} }}e^{-\frac{(x-\mu)^{2}}{2\sigma^{2}}} \]

  • Used frequently to represent real-valued random variables whose distributions are not known.
  • Its importance is derived from the central limit theorem that states, under some conditions, the average of many samples of a random variable is itself a random variable that converges to a Gaussian distribution as it increases.
  • \(E[X] = \mu\)
  • \(Var[X] = \sigma^{2}\)

Python Code: Gaussian Distribution

To create Gaussian distributed data using numpy:

import numpy as np

mu = 0
sigma = 1
size = (1000,1)

data = np.random.normal(mu, sigma, size)

Beta Distribution

\[ f_{X}(x) = {\frac {\Gamma (\alpha +\beta )}{\Gamma (\alpha )\Gamma (\beta )}}\,x^{\alpha -1}(1-x)^{\beta -1} \]

where \(\Gamma\) is the gamma function defined as:

\[ \Gamma (z)=\int _{0}^{\infty}t^{z-1}e^{-t}\,dt \]

  • Gamma functions are used to model factorial functions of complex numbers \(z\).
  • Beta functions are used to model behavior of random variables in intervals of finite length.
  • \(E[X] = \frac{\alpha}{\alpha+\beta}\)
  • \(Var[X] = \frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}\)

Python Code: Beta Distribution

To create Beta distributed data using numpy:

import numpy as np 

alpha = 0.5
beta = 0.5
size = (1000,1)

data = np.random.beta(alpha, beta, size)