Lecture 3 - Part 2

Contents

Well-Known Distributions

In the last part, we covered most of the fundamental concepts which are required to understand the detection theory. The only remaining bit is introduction to some commonly encountered probability distribution and methods for simulating the random variables. We will start with these two concepts and then do a quick tour of detection theory in this part.

Bernoulli Distribution

P(X=1)=p,P(X=0)=1p\begin{equation} P(X=1) = p, \quad P(X=0) = 1-p \end{equation}
  • Mean: pp
  • Variance: p(1p)p(1-p)

Binomial Distribution

Number of successes in nn independent Bernoulli trials:

P(X=k)=(nk)pk(1p)nk,k=0,1,,n\begin{equation} P(X=k) = \binom{n}{k} p^k (1-p)^{n-k}, \quad k=0,1,\dots,n \end{equation}
  • Mean: npnp
  • Variance: np(1p)np(1-p)

Geometric Distribution

Number of trials until first success:

P(X=k)=(1p)k1p,k=1,2,\begin{equation} P(X=k) = (1-p)^{k-1}p, \quad k=1,2,\dots \end{equation}
  • Mean: 1p\tfrac{1}{p}
  • Variance: 1pp2\tfrac{1-p}{p^2}

Poisson Distribution

Models rare events:

P(X=k)=λkeλk!,k=0,1,2,\begin{equation} P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}, \quad k=0,1,2,\dots \end{equation}
  • Mean: λ\lambda
  • Variance: λ\lambda

Uniform Distribution

fX(x)=1ba,axb\begin{equation} f_X(x) = \frac{1}{b-a}, \quad a \leq x \leq b \end{equation}
  • Mean: a+b2\tfrac{a+b}{2}
  • Variance: (ba)212\tfrac{(b-a)^2}{12}

Normal (Gaussian) Distribution

fX(x)=12πσ2exp ⁣((xμ)22σ2)\begin{equation} f_X(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\!\Bigg(-\frac{(x-\mu)^2}{2\sigma^2}\Bigg) \end{equation}
  • Mean: μ\mu
  • Variance: σ2\sigma^2

Exponential Distribution

fX(x)=λeλx,x0\begin{equation} f_X(x) = \lambda e^{-\lambda x}, \quad x \geq 0 \end{equation}
  • Mean: 1λ\tfrac{1}{\lambda}
  • Variance: 1λ2\tfrac{1}{\lambda^2}

Rayleigh Distribution

A continuous probability distribution for non-negative random variables, often used to model the magnitude of a vector with two independent and identically distributed Gaussian components (e.g., fading in wireless channels).
PDF:

f(x;σ)=xσ2ex2/(2σ2),x0,σ>0\begin{equation} f(x;\sigma) = \frac{x}{\sigma^2} e^{-x^2/(2\sigma^2)}, \quad x \geq 0, \, \sigma > 0 \end{equation}

Gamma Distribution

A two-parameter family of continuous probability distributions that generalizes the exponential distribution and is often used to model waiting times.
PDF:

f(x;k,θ)=1Γ(k)θkxk1ex/θ,x0,k>0,θ>0\begin{equation} f(x;k,\theta) = \frac{1}{\Gamma(k)\theta^k} x^{k-1} e^{-x/\theta}, \quad x \geq 0, \, k > 0, \, \theta > 0 \end{equation}

where Γ(k)\Gamma(k) is the Gamma function.

Chi-Square (χ²) Distribution

A special case of the Gamma distribution with shape parameter k/2k/2 and scale parameter 22. It arises as the distribution of a sum of squares of kk independent standard normal random variables.
PDF:

f(x;k)=12k/2Γ(k/2)xk/21ex/2,x0,k>0\begin{equation} f(x;k) = \frac{1}{2^{k/2}\Gamma(k/2)} x^{k/2 - 1} e^{-x/2}, \quad x \geq 0, \, k > 0 \end{equation}

Generating Random Variables in Python

Method 1: Using Inverse Transform approach

Here’s how we do it:

  1. Step 1: Generate 𝑈Uniform(0,1)𝑈∼\text{Uniform}(0,1)
  2. Step 2: Transform using the inverse CDF (quantile function) of the distribution.

Below is Python code for all 10 distributions using inverse transform sampling:

Method 1: Inverse Transform Sampling

Loading editor...
No output yet. Click "Run Python" to execute.

Method 2: Using Library Functions

Not all RVs have closed-form PDF and CDFs, sometimes its better to perform Rejection Sampling to generate the variable. We do not dwell into the details in these notes. For the sake of this book, you can use builtin python libraries to generate the RVs as follows:

Method 2: Using Library Functions

Loading editor...
No output yet. Click "Run Python" to execute.

Note

As a self-study task familiarise yourself with the cumulative distribution functions of these common random variables.

Revisiting Gaussian Distribution

The Gaussian probability density function (PDF) (also referred to as Normal PDF) is defined as

pX(x)=12πσ2exp ⁣((xμ)22σ2)<x<,\begin{equation} p_X(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\!\Bigg(-\frac{(x-\mu)^2}{2\sigma^2}\Bigg) \qquad -\infty < x < \infty, \end{equation}

where μ\mu is the mean and σ2\sigma^2 is the variance. It is denoted by N(μ,σ2)\mathcal{N}(\mu,\sigma^2) and we indicate XN(μ,σ2)X \sim \mathcal{N}(\mu,\sigma^2) to say that XX follows Normal distribution. If μ=0\mu=0 then the moments are given by:

E(Xn)={135(n1)σnn is even0n is odd.\begin{equation} \mathbb{E}(X^n)= \begin{cases} 1\cdot3\cdot5\cdot\cdot\cdot(n-1)\sigma^n & n \text{ is even} \\ 0 & n \text{ is odd.} \end{cases} \end{equation}

If μ>0\mu>0 then, we can define the nthn^{\text{th}} moment as:

E((X+μ)n)=k=0n(nk)E(Xk)μnk,\begin{equation} \mathbb{E}((X+\mu)^n)= \sum_{k=0}^{n} \binom{n}{k} \mathbb{E}(X^k)\mu^{n-k}, \end{equation}

with E(Xk)\mathbb{E}(X^k) can be computed from the previous equation (Eq. (12)).

As can be seen from this interactive graph, changing the mean changes the location of the distribution, while changing the variance controls the spread. The cumulative distribution of standard Normal distribution (μ=0\mu=0 and σ2=1\sigma^2=1) is given by:

Φ(z)=z12πexp(12t2)dt.\begin{equation} \Phi(z) = \int_{-\infty}^{z} \frac{1}{\sqrt{2\pi}} \exp \Big(-\frac{1}{2}t^2 \Big)dt. \end{equation}

Often it is more convenient to use complementary CDF, i.e., 1FX(z)=1Φ(z)1-F_X(z)= 1-\Phi(z) the probability that the XX exceeds a certain value zz. This is also known as right tail probability. Then we can express,

P{X>z}=Q(z)=1Φ(z)=z12πexp(12t2)dt. \begin{equation} \begin{split} P\{X>z\} &= Q(z) = 1- \Phi(z)\\ &= \int_{z}^{\infty} \frac{1}{\sqrt{2\pi}} \exp \Big(-\frac{1}{2}t^2 \Big)dt. \end{split} \end{equation}

Multivariate Gaussian Distribution

In previous section, we explored univariate Gaussian distribution. This can be generalised easily to multivariate distribution. Consider, x=[x1,x2,...,xn]\boldsymbol{x}=[x_1,x_2,...,x_n] where xiN(μi,σi2)x_i \sim \mathcal{N}(\mu_i,\sigma_i^2) then vector x\boldsymbol{x} has multivariate Gaussian distribution. Mathematically,

pX(x;μ,Σ)=1(2π)N2Σ12exp((xμ)TΣ1(xμ)2),\begin{equation} p_{\boldsymbol{X}}(\boldsymbol{x};\boldsymbol{\mu},\boldsymbol{\Sigma})= \frac{1}{(2\pi)^{\frac{N}{2}} |\boldsymbol{\Sigma}|^{\frac{1}{2}}} \exp \Bigg( -\frac{(\boldsymbol{x}-\boldsymbol{\mu})^{T}\boldsymbol{\Sigma}^{-1}(\boldsymbol{x}-\boldsymbol{\mu})}{2}\Bigg), \end{equation}

where X=[x1,x2,...,xn]\boldsymbol{X}=[x_1,x_2,..., x_n] is the vector collection of RVs, μ=[μ1,μ2,...,μN]\boldsymbol{\mu}=[\mu_1,\mu_2,...,\mu_N] is a mean vector, and Σ\boldsymbol{\Sigma} is a N×NN\times N covariance matrix. We will come back to the covariance matrix in few moments. For now consider it to be matrix containing relationship between xix_i's. When N=2N=2, we have special case of Bi-variate Gaussian distribution. A Bi-variate Gaussian distribution can be visualised in 3D as follows:

Method 2: Using Library Functions

Loading editor...
No output yet. Click "Run Python" to execute.

In the plot above, try changing the 0.5 values to 0, and observe what happens to the shape of the distribution. To understand what is happening here, let us dive into concept of covariance.

Covariance Matrix

The covariance matrix's entries can be written as follows:

[C]i,j=Cov(xi,xj)=E((xiE(xi))(xjE(xj))), where i=1,...,N and j=1,...,N.\begin{equation} \begin{split} [\boldsymbol{C}]_{i,j}= \text{Cov}(x_i,x_j)= \mathbb{E}((x_i-\mathbb{E}(x_i))(x_j-\mathbb{E}(x_j))),\\ \text{ where } i= 1,...,N \text{ and } j=1,...,N. \end{split} \end{equation}

So essentially, the co-variance matrix contains how two random variable say xix_i and xjx_j change together. Covariance quantifies how much two variables are linearly related. The covariance only captures the linear relationship and not any other types of relationship between these random variables. Consider the term (xiE(xi))(xjE(xj))(x_i-\mathbb{E}(x_i))(x_j-\mathbb{E}(x_j)):

  1. If both xix_i and xjx_j are above their respective mean values this term is positive. Showing that both of these variables move together, in a straight line sense. Essentially, Cov(xi,xj)>0\text{Cov}(x_i,x_j)>0.
  2. If one of these goes down while another one up, then they are negatively correlated. Essentially, Cov(xi,xj)<0\text{Cov}(x_i,x_j)<0.
  3. If both xix_i and xjx_j are uncorrelated then Cov(xi,xj)=0\text{Cov}(x_i,x_j)=0. Notice that if two RVs are independent then Cov(xi,xj)=0\text{Cov}(x_i,x_j)=0 but other way around is not true.

Understanding Covariance through Contour Plots

Explore the figure below showing a contour plot. You can observe how the sign of covariance affects the shape and orientation of the contours.

Positive Covariance

  • The contours are elliptical and tilted upward.
  • This indicates that as X increases, Y tends to increase too.
  • In other words, the two variables move together.

Negative Covariance

  • The contours are elliptical but tilted downward.
  • This indicates that as X increases, Y tends to decrease.
  • The variables move in opposite directions.

Zero Covariance

  • The contours are circular (or axis-aligned ellipses).
  • This means there is no linear relationship between X and Y.
  • They may still have non-linear dependence, but linearly they are independent.

You can also visualize the same covariance in a 3D surface plot, which makes the tilt of the density even more visually obvious.

When Σ=σ2IN\boldsymbol{\Sigma}=\sigma^2 \boldsymbol{I}_N with

IN=[1000010000100001]\mathbf{I}_N = \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix}

we often say that the X\boldsymbol{X} has isotropic Gaussian distribution. We will come back to these concepts again when we look at Time-Series Analysis in future discussion. For now, we have explored the fundamental concepts to build our background and are all set to explore basic detection problems.

Reference

[1] Kay, Steven M. Fundamentals of statistical signal processing: Detection theory. Prentice-Hall, Inc., 1993. Read Chapter 2 to familiarise yourself with some of the concepts discussed here.