Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Probability templates

Introduction

Several probability distributions have been studied in depth. Templates like this allow us to model data generated from an experiment quickly. Random variable templates are so useful that several programming languages have optimized how to compute probabilities, expected values, and higher moments.

We will study parametric distributions for random variables. A set of parameters---constants---determine how our random variable assigns probabilities to outcomes.

Discrete Distributions

The Bernoulli Distribution

The Bernoulli distribution assigns probabilities to a random variable whose support contains the values 0 and 1. The Bernoulli distribution has a single parameter, often denoted θ\theta, that controls how probabilities are assigned to these two values, 0 and 1.

To communicate that a random variable ZZ has a Bernoulli distribution with parameter θ\theta, we write:

Z∼Bernoulli(θ)\begin{align} Z \sim \text{Bernoulli}(\theta) \end{align}

The parameter θ\theta can take any value between 0 and 1 inclusive, or θ∈[0,1]\theta \in [0,1]. The allowable values a set of parameters can take is called the parameter space.

The support of ZZ is supp(Z)={0,1}\text{supp}(Z) = \{0,1\}, and the probability mass function for the random variable ZZ is:

P(Z=z)=fZ(z)={θ,if z=11−θ,if z=0\begin{align} P(Z=z) = f_{Z}(z) = \begin{cases} \theta, & \text{if } z=1 \\ 1- \theta, & \text{if } z=0 \end{cases} \end{align}

We can use the probability mass function to compute the expectation:

E(Z)=fZ(1)⋅1+fZ(0)⋅0=fZ(1)⋅1=fZ(1)=θ\begin{align} \mathbb{E}(Z) &= f_{Z}(1) \cdot 1 + f_{Z}(0) \cdot 0 \\ &= f_{Z}(1) \cdot 1 = f_{Z}(1) \\ &= \theta \end{align}

And we can use the probability mass function to compute the variance:

V(Z)=(1−θ)2fZ(1)+(0−θ)2fZ(0)=(1−θ)2θ+θ2(1−θ)=θ(1−θ)[(1−θ)+θ]=θ(1−θ)\begin{align} V(Z) &= (1 - \theta)^{2} f_{Z}(1) + (0-\theta)^{2} f_{Z}(0) \\ &= (1 - \theta)^{2} \theta + \theta^{2} (1-\theta) \\ &= \theta(1-\theta) \left[ (1-\theta) + \theta \right] \\ &= \theta(1-\theta) \end{align}

Example: Define Z∼Bernoulli(0.45)Z \sim \text{Bernoulli(0.45)}. Then:

supp(Z)={0,1}P(Z=0)=0.55P(Z=1)=0.45E(Z)=0.45V(Z)=0.45(0.55)=0.25\begin{align} \text{supp}(Z) &= \{0,1\} \\ P(Z=0) &= 0.55 \\ P(Z=1) &= 0.45 \\ \mathbb{E}(Z) &= 0.45 \\ V(Z) &= 0.45(0.55) = 0.25 \end{align}

Example: A clinical trial enrolls patients and follows them for one year. The clinical team wants to understand the proportion of patients that experience or do not experience an adverse event. We could model whether each patient either experiences or does not experience an adverse event using a Bernoulli distribution. Define ZiZ_{i} as a Bernoulli-distributed random variable for the ithi^\text{th} patient in the study. When Zi=1Z_{i} = 1, the ithi^{\text{th}} patient experienced an adverse event; otherwise, Zi=0Z_{i} = 0.

The Binomial distribution

A random variable XX distributed Binomial(N,θ)(N,\theta) has as support supp(X)={0,1,2,3,4,5,⋯ ,N}supp(X) = \{0,1,2,3,4,5,\cdots,N\}, and the probability mass function is

P(X=x)=(Nx)θx(1−θ)N−x\begin{align} P(X=x) = \binom{N}{x} \theta^{x}(1-\theta)^{N-x} \end{align}

where (Nx)\binom{N}{x} is called a binomial coefficient and is defined as (Nx)=N!x!(N−x)!\binom{N}{x} = \frac{N!}{x!(N-x)!}.

Where x!x! is read “x factorial” and is defined as

x!=x(x−1)(x−2)(x−3)⋯(2)(1)x!=x (x-1) (x-2) (x-3) \cdots (2) (1)

The binomial coefficient is often read “N choose x” and counts the number of ways one can choose xx items from a set of NN items where the order that the xx items is chosen does not matter. For example, (104)\binom{10}{4} counts the number of ways to choose 4 items from a set of 10 items where the order we selected each of the four items does not matter.

The expected value and variance of XX are

E(X)=NθV(X)=Nθ(1−θ)\begin{align} \mathbb{E}(X) &= N\theta \\ V(X) &= N\theta(1-\theta) \end{align}

Given N observations, the binomial distribution assigns probabilities to the number of observations that experience an outcome of interest where we assume that the probability any single observation experiences the event is θ\theta.

Example Imagine we randomize 200 patients in a clinical trial where 100 are enrolled to receive a novel treatment and 100 are enrolled to receive a control treatment. In the treatment group, 10 patients experience an adverse event from the treatment and in the control group 15 patients experience an adverse event. In previous work we found that the probability any one patient experiences an adverse event in the treatment group is 0.02 and in the control group is 0.04. We can define a random variable T∼Bin(100,0.02)T \sim \text{Bin}(100,0.02) that assigns a probability to the number of patients who experience an adverse event and define a random variable C∼Bin(100,0.04)C \sim \text{Bin}(100,0.04) that assigns probabilities to the number of patients who experience an event in the control group.

The Poisson distribution

If a random variable XX has a Poisson distribution then the support of XX is all non-negative integers or supp(X)={0,1,2,3,4,...}supp(X) = \{0,1,2,3,4,...\}, and the probability mass function is

P(X=x)=e−λλxx!\begin{align} P(X=x) = \frac{e^{-\lambda} \lambda^{x}}{x!} \end{align}

where x!x! is read “x factorial” and is defined as

x!=x(x−1)(x−2)(x−3)⋯(2)(1)x!=x (x-1) (x-2) (x-3) \cdots (2) (1)

For example, 5!=(5)(4)(3)(2)(1)=605! = (5)(4)(3)(2)(1) = 60. The parameter space for the single parameter λ\lambda is all positive real numbers or λ∈(0,∞)\lambda \in (0,\infty).

The expected value and variance are

E(X)=λV(X)=λ\begin{align} \mathbb{E}(X) &= \lambda \\ V(X) &= \lambda \end{align}

A random variable that follows a Poisson distribution often corresponds to an experiment where the quantity of interest is a rate. A Poisson random variable assigns probabilities to the number of occurrences of an event in a given time period. The parameter λ\lambda describes the average number of occurences per time unit.

Example The owner of a cafe wants records the number of espressos they produce each day and wants to characterize the probability they produce 0, 1, 2, etc. espressos. For one month the owner records the number of espressos produced per day and find on average that they produce 25 per day. We can model the number of espressos per day as a random variable X∼Pois(25)X \sim \text{Pois}(25).

Homework

Warmup

  1. Let X∼Bernoulli(0.25)X \sim \text{Bernoulli}(0.25). Then please compute the P(X=1)P(X=1)

  2. Let Y∼Binomial(10,0.25)Y \sim \text{Binomial}(10, 0.25). Then please compute the P(Y=2)P(Y=2)

  3. Let Z∼Poisson(2.5)Z \sim \text{Poisson}(2.5). Then please compute the P(Z=3)P(Z=3)

Final destination

A fictitious dataset was collected below over the course of 12 fictious hours. The first row is the first hour of observation, the second row is the second hour of observation, etc. The columns represent different settings or ‘scenes’, number of people at risk, number of deaths in general during that time priod, number of strange incidents that had occured in that time period and scenece, and whether one of the “targets” from the field died.

  1. First, estimate the probability that the target dies by computing the proportion of deaths over the 12 hour time period.

  2. Using 4, please write down a random variable and probability density to characterize whether a target in the 13th hour dies or does not.

  3. In final destination, strange incidents occur before a target dies in the movie. First, lets estimate the rate of strange incidents per hour with the mean.

  4. Using 6, please write down a random variable and probability density to characterize the number of strange incidents in the 13th hour.

  5. Use 6 and 7 to please compute the probability of 5 strange incidents occuring in the 13th hour.

ScenePeople at riskDeathsStrange incidentsTarget dies?
Kitchen3141
Elevator5020
Highway8261
Bathroom1131
Workshop4150
Restaurant6020
Hospital3141
Parking garage5271
Gym4010
Construction site7261
Apartment2131
Train platform6020