06 Probability Density Functions

Contents

06 Probability Density Functions#

Two simple examples of Probability Density Functions (PDFs): the Uniform distribution and the Normal (Gaussian) distribution.

  1. Uniform Distribution

The PDF of a Uniform distribution in the interval [a, b] is:

f(x) = 1 / (b - a) for a <= x <= b
f(x) = 0 otherwise

This means that all outcomes in the interval [a, b] are equally likely. For example, if a = 0 and b = 1, then the probability of x being between 0 and 1 is 1, and outside this interval is 0.

While it’s true that the total probability (the area under the curve of the probability density function) must be 1, the value of the density function itself can be greater than 1. The height of the probability density function is 2 for all x in [0, 0.5], even though the probabilities themselves must be between 0 and 1. This is because the density function represents probability per unit of x, and the total probability is obtained by integrating the density function over the range of x, which gives an area (probability) of 1.

def uniform_pdf(x, a, b):
    return 1 / (b - a) if a <= x <= b else 0

print(uniform_pdf(3, 0, 1))
print(uniform_pdf(0.1, 0, 0.5))
0
2.0
  1. Normal Distribution

The PDF of a Normal distribution with mean μ and standard deviation σ is:

f(x) = (1 / (σ * sqrt(2π))) * exp(-(x - μ)^2 / (2σ^2))

This distribution is bell-shaped and is determined by the mean μ and the standard deviation σ. The highest probability is at x = μ, and the probability decreases as x moves away from μ. For example, if μ = 0 and σ = 1, then the probability of x is highest at 0 and decreases as x moves away from 0.

Remember that these are continuous distributions, so the PDF gives the probability density at a given point, not the probability of that point. The probability of a range of values is given by the integral of the PDF over that range.

import numpy as np

def normal_pdf(x, mu, sigma):
    sqrt_two_pi = np.sqrt(2 * np.pi)
    return (np.exp(-(x-mu)**2 / 2 / sigma**2) / (sqrt_two_pi * sigma))

Question#

for \(a<b\) and \(∫_{a}^{b} f_X(x)dx \in [0,1]\), represent the probability that the value of X falls between a and b

Explanation YES. For a continuous random variable X with a probability density function \(f_X(x)\), the integral of \(f_X(x)\) from a to b represents the probability that X falls within the interval \([a, b]\).

Mathematically, this is represented as:

\[P(a <= X <= b) = ∫_{a}^{b} f_X(x) dx\]