title: Probability distributions: templatesIntroduction¶
There exist several probability distributions that 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 computer 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 who support contains the values 0 and 1. The Bernoulli distribution has a single parameter, often denoted , that controls how probabilities are assigned to these two values 0 and 1.
To communicate that a random variable has a Bernoulli distribution with parameter , we write
The parameter can take any value between 0 and 1 inclusive, or . The allowable values a set of parameters can take is called the .
The support of is , and the probability mass function for the random variable is
We can use the probability mass function to compute the expectation
and we can use the probability mass function to compute the variance
Define . Then , , the , and .
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 as a Bernoulli distributed random variable for the patient in the study. When = 1 the patient experienced an adverse event and 0 otherwise.
The Geometric distribution¶
If a random variable has a Geometric distribution then the support is the values and the probability mass function is
A random variable that has a geometric distribution has a single parameter that can take any value between 0 and 1 inclusive, or .
The expected value and variance are
A random variable that follows the Geometric distribution often corresponds to an experiment where there is a probability that an event occurs (often called a success), a probability an event does not occur (often called a failure). We assume that each experiment is independent from the previous experiments. The Geometric distribution assigns a probability to the the number of times the experiment is repeated until the event occurs (i.e. the number of repeated experiments until success).
Suppose we want to study the number of times a diagnostic test needs to be implemented until that test detects the presence of viral infection. Further assume we have found in a laboratory setting that the probability this test detects a viral infection is 0.70. We could model the number of attempts until detection as a random variable , and the rv would follow a geometric distribution with parameter value equal to 0.70 or .
The Poisson distribution¶
If a random variable has a Poisson distribution then the support of is all non-negative integers or , and the probability mass function is
where is read "x factorial" and is defined as
For example, . The parameter space for the single parameter is all positive real numbers or .
The expected value and variance are
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 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 .
The Binomial distribution¶
A random variable distributed Binomial has as support , and the probability mass function is
where is called a binomial coefficient and is defined as . The binomial coefficient is often read "N choose x" and counts the number of ways one can choose items from a set of items where the order that the items is chosen does not matter. For example, 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 are
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 .
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 that assigns a probability to the number of patients who experience an adverse event and define a random variable that assigns probabilities to the number of patients who experience an event in the control group.
The Discrete Uniform distribution¶
A random variable has a uniform discrete distribution is this random variable has a support equal to and a probability mass function equal to
where count the number of outcomes between and inclusive.
The expect6ed value and variance of are
The parameters and for a uniform discrete distribution can take any integer value so long as the constraint is satisfied.
A game of dice is played between two friends. The die that roll has six sides. We can model the probability the first player rolls any of the one through six values as and the probability the second player rolls values between one and six as .
Continuous distributions¶
Up until this point we have characterized discrete sample spaces and random variables that are defined on discrete sample spaces, called discrete random variables.
A continuous sample space, , is a subset of the real line . There are an infinite, uncountable number of outcomes possible in a continuous sample space and this introduces some oddities when we try to assign probabilities on a sample space like this.
A continuous random variable is a function from a continuous sample space to the real line.
Discrete to continuous: Points to intervals¶
Consider a discrete sample space with outcomes , and define a random variable that has a uniform discrete distribution with parameters 0 and 1 or .Because there are 5 outcomes the probability of each outcome is .
Let’s increase the size of our discrete sample space to contain 100 values between 0 and 1 by setting . If we define a uniformly distributed random variable on this space then the probability of each outcome is 1/100.
As we increase the number of points in our sample space, the probability assigned to each individual point will shrink towards zero. [In a continuous space the probability of any individual value is zero.]{.underline}
Because the for a continuous random variable defined on a continuous , we need a new way to define probabilities for a continuous random variables.
Densities¶
For a continuous random variable with support , where is an interval of the real line, we will assign non-negative probabilities to any interval that is a subset of according to a probability density function .
A probability density function will help us compute the probability over an interval in . A probability density must have values that are non-negative (i.e. on or above the horizontal line x=0 in an xy-plane) and the area under this probability density function for the set must equal one.
The probability that a random variable with pdf assigns to the interval is the area under from a to b.
<picture>
Uniform continuous distribution¶
For a discrete random variable, , the discrete uniform distribution from to assigns the same probability to every outcome .
For a continuous random variable , the continuous uniform distribution from to or will assign the same probability to any interval of the same length between the values and .
The probability density function on the set is
To compute the probability of an interval, lets say where and , we need to compute the area under from to .
<picture>
The area under is equivalent to the area of a rectangle with width and height . This area equals and so
We can also define the cumulative density function (cdf), , as
The cdf is an important function for continuous random variables because this function inputs a value and returns the probability over all values less than ---an interval.
<picture>
The expected value and variance are
Just-in-time integration¶
We recognized that the area under the probability density function of a continuous uniform random variable is the same as the area of a rectangle.
But there are several continuous random variables with non-linear densities that are not easy to compute. We need a special tool and special notation to handle computing areas under these densities.
Suppose we define a continuous random variable that has two parameters, and , with the following probability density function
defined over all negative and positive numbers or .
<pciture>
The area under this density is not at all straight forward to compute. However, we may be able to use the area of several rectangles---areas that we can compute---to approximate the area under this more complicated curve. Approximating the area under a curve with a set of simpler curves is called Riemann integration.
Lets suppose we are interested in
which is the area under from the value -1 to the value 1.
<picture>
One way to approximate this area is to split up the interval into (lets say) 20 pieces . For each smaller interval we can choose a single point , where is a point between -1 and -9/10, the point is a point between -9/10 and -8/10 and so on. We can create rectangles with width and height and sum these rectangles to approximate the area under .
<picutre>
The area of these rectangles is
As we split this interval into more and more intervals the rectangles will better and better approximate the area under .
<picture>
If these exists a number such that the more splits we create the approximate area gets closer to , then is called the integral of from -1 to 1 and is the exact area under .
We write
to represent the area under the probability density between the values -1 and 1.
For a continuous random variable the integral from to a value is the area of a rectangle. .
The cumulative density function evaluate at a value for a random variable is the area under the probability density function from the smallest possible value in the support of to . This can be represented with an integral .
Normal Distribution¶
A continuous random variable has a Normal distribution with parameters and if the support of is all real numbers and the probability density function is
The normal distribution has several important properties that apply only to the normal distribution.
The expected value and variance are equal to distinct parameters¶
The expected value and variance of are
For most continuous distributions the expected value and variance are a combination of all the paramter values. The normal distribution is unique in that the expected value only contains a single parameter and the variance only contains a unique parameter .
Shifting and scaling by a constant is easy¶
If a random variable where then the distribution of is . If a random variable where then the distribution of is .
These shifting and scaling properties are unique to the normal distribution.
Quantiles and the quantile function¶
A quantile is a value such that
where .
If is a discrete random variable the may not equal . However when is a continuous random variable the will equal and so for a continuous random variable the quantile is a value such that
Define .Then The 97.5th quantile for is the value 1.96 because . The 2.5th quantile for is the value -1.96 because . The 90th quantile for is the value 1.28 because and so the value -1.28 is the 10th quantile because .
Define . Then the 90th quantile is the value 5. This is because and .
We can also define a Quantile function for a random variable that takes as input values of and returns the value such that
Often we can think of the quantile function as the inverse of the cumulative mass (density) function. For a random variable , the cmf or cdf takes as input values in the support of and returns the probability that . Instead, the Quantile function takes as input a probability and returns the value such that and .
Exercises¶
Let
P(X=0) = ?
P(X=1) = ?
Please compute
Please compute
Define the
Let , and show that
Let , and show that
Let , and let be the following function of : $$\begin{aligned} Z(y) = \begin{cases} 1 & if y = 0\ 0 & if y = 1 \end{cases}
\end{aligned}$Z$ follow and why?
Design an experiment (short description) and define a random variable that may follow a geometric distribution. In the context of your experiment, how would you communicate to another without statistical expertise?
Define a random variable with a binomial distribution .
Compute
Compute
Describe to someone who may not have statistical expertise what means? Be sure to include assumptions about the Binomial distribution and how the parameters relate to this probability.
For what value of is the highest? Why does this make sense intuitively?
Suppose
Compute
Compute
Compute
Let . What is the distribution of ?
Let . What is the distribution of ?
Compute
Suppose we define a new random variable with support and probability density function $$\begin{aligned} f_{W}(w) = 2w
\end{aligned}$$
Compute
Compute
Let be a continuous random variable. Is ? Why or why not?