Probability Cheatsheet
Probability Cheatsheet
431x Probability – The Science of Conditioning and Independence Combinations Given a set of n elements, the number of ways of
constructing an ordered sequence of k distinct elements is
Uncertainty and Data n n!
This is a cheat sheet for probability based on the online course given by
Conditioning and Bayes’ Rule =
k k!(n − k)!
Prof. John Tsitsiklis and Prof. Patrick Jaillet. Compiled by Janus B. Conditional Probability We denote the probability of A, given that B
Advincula. occurred by P(A|B) and this is defined as Subsets The number of subsets of {1, . . . , n} is
Last Updated December 8, 2020 P(A ∩ B) n
P(A|B) = , P(B) > 0.
X n n n
n
P(B) = + ··· + =2 .
k 0 n
Probability Models and Axioms Conditional probabilities share properties of ordinary probabilities.
k=0
If c is a constant, E [c] = c. calculus, to get from PDF back to CDF we can integrate:
Z x
Law of Iterated Expectations
Let X be a r.v. and let Y = g(X). Then, F (x) = f (t)dt E [E [X|Y ]] = E [X]
X −∞
E [Y ] = E [g(X)] = g(x)pX (x). Law of Total Variance
0.30
1.0
x
Var(X) = E [Var (X|Y )] + Var (E [X|Y ])
0.8
Linearity of Expectation
0.20
Sum of a Random Number of Independent RVs Let
0.6
CDF
PDF
Y = X1 + · · · + XN where N is a random variable. Then,
E [aX + b] = aE [X] + b
0.4
0.10
Var(Y ) = E [Var(Y |N )] + Var (E [Y |N ])
0.2
Variance and Standard Deviation = E[N ] Var(X) + (E[X]) Var(N )
2
0.00
0.0
−4 −2 0 2 4 −4 −2 0 2 4
Definition of Variance Variance is a measure of the spread of a PMF. x x
+
+
+
+
Let X1 , X2 , X3 , . . . be i.i.d. with mean µ and variance σ 2 . The sample n(X̄n − µX ) D
mean is 0 T1 T2 T3 T4 T5 −→ N (0, 1)
σX
X1 + · · · + Xn
Mn = . Count-Time Duality Consider a Poisson process of emails arriving in an
n inbox at rate λ emails per hour. Let Tn be the time of arrival of the nth Markov Chains
The Weak Law of Large Numbers states that: email (relative to some starting time 0) and Nt be the number of emails
that arrive in [0, t]. Let’s find the distribution of T1 . The event T1 > t, the Definition
for > 0, P (|Mn − µ| ≥ ) → 0, as n → ∞. event that you have to wait more than t hours to get the first email, is the
same as the event Nt = 0, which is the event that there are no emails in the 5/12 7/12 7/8
Transformations first t hours. So
1 1/2 1/3 1/4
1 2 3 4 5
One Variable Transformations Let’s say that we have a random P (T1 > t) = P (Nt = 0) = e
−λt
−→ P (T1 ≤ t) = 1 − e
−λt 1/2 1/4 1/6 1/8
variable X with PDF fX (x), but we are also interested in some function of
X. We call this function Y = g(X). Also let y = g(x). If g is differentiable Thus we have T1 ∼ Expo(λ). By the memoryless property and similar A Markov chain is a random walk in a state space, which we will assume
and strictly increasing (or strictly decreasing), then the PDF of Y is reasoning, the interarrival times between emails are i.i.d. Expo(λ), i.e., the is finite, say {1, 2, . . . , M }. We let Xt denote which element of the state
differences Tn − Tn−1 are i.i.d. Expo(λ). space the walk is visiting at time t. The Markov chain is the sequence of
dx −1 d −1 random variables tracking where the walk is at all points in time,
fY (y) = fX (x) = fX (g (y)) g (y)
dy dy X0 , X1 , X2 , . . . . By definition, a Markov chain must satisfy the Markov
Order Statistics property, which says that if you want to predict where the chain will be at
The derivative of the inverse transformation is called the Jacobian. a future time, if we know the present state then the entire past history is
Two Variable Transformations Similarly, let’s say we know the joint Definition Let’s say you have n i.i.d. r.v.s X1 , X2 , . . . , Xn . If you arrange irrelevant. Given the present, the past and future are conditionally
PDF of U and V but are also interested in the random vector (X, Y ) them from smallest to largest, the ith element in that list is the ith order independent. In symbols,
defined by (X, Y ) = g(U, V ). Let statistic, denoted X(i) . So X(1) is the smallest in the list and X(n) is the P (Xn+1 = j|X0 = i0 , X1 = i1 , . . . , Xn = i) = P (Xn+1 = j|Xn = i)
! largest in the list.
∂u ∂u
∂(u, v)
= ∂x ∂y Note that the order statistics are dependent, e.g., learning X(4) = 42 gives State Properties
∂v ∂v
∂(x, y) ∂x ∂y us the information that X(1) , X(2) , X(3) are ≤ 42 and X(5) , X(6) , . . . , X(n) A state is either recurrent or transient.
be the Jacobian matrix. If the entries in this matrix exist and are
are ≥ 42. If you start at a recurrent state, then you will always return back
continuous, and the determinant of the matrix is never 0, then Distribution Taking n i.i.d. random variables X1 , X2 , . . . , Xn with CDF to that state at some point in the future. nYou can check-out any
F (x) and PDF f (x), the CDF and PDF of X(i) are: time you like, but you can never leave. n
fX,Y (x, y) = fU,V (u, v)
∂(u, v) Otherwise you are at a transient state. There is some positive
probability that once you leave you will never return. nYou don’t
n
∂(x, y) X n k n−k
FX(i) (x) = P (X(i) ≤ x) = F (x) (1 − F (x))
k have to go home, but you can’t stay here. n
The inner bars tells us to take the matrix’s determinant, and the outer bars k=i
A state is either periodic or aperiodic.
tell us to take the absolute value. In a 2 × 2 matrix,
If you start at a periodic state of period k, then the GCD of the
n − 1
i−1 n−i
fX(i) (x) = n F (x) (1 − F (x)) f (x)
a b i−1 possible numbers of steps it would take to return back is k > 1.
= |ad − bc|
c d Uniform Order Statistics The jth order statistic of Otherwise you are at an aperiodic state. The GCD of the possible
i.i.d. U1 , . . . , Un ∼ Unif(0, 1) is U(j) ∼ Beta(j, n − j + 1). numbers of steps it would take to return back is 1.
Transition Matrix Continuous Distributions Gamma Distribution
Let the state space be {1, 2, . . . , M }. The transition matrix Q is the Gamma(3, 1) Gamma(3, 0.5)
M × M matrix where element qij is the probability that the chain goes Uniform Distribution
from state i to state j in one step:
0.10
0.2
Let us say that U is distributed Unif(a, b). We know the following:
PDF
qij = P (Xn+1 = j|Xn = i) Properties of the Uniform For a Uniform distribution, the probability
0.05
0.1
of a draw from any interval within the support is proportional to the length
To find the probability that the chain goes from state i to state j in exactly of the interval. See Universality of Uniform and Order Statistics for other
0.00
m steps, take the (i, j) element of Qm .
0.0
properties. 0 5 10 15 20 0 5 10 15 20
x x
(m) Example William throws darts really badly, so his darts are uniform over
qij = P (Xn+m = j|Xn = i) the whole room because they’re equally likely to appear anywhere.
Gamma(10, 1) Gamma(5, 0.5)
0.10
William’s darts have a Uniform distribution on the surface of the room.
If X0 is distributed according to the row vector PMF p
~, i.e.,
0.10
The Uniform is the only distribution where the probability of hitting in any
pj = P (X0 = j), then the PMF of Xn is p ~Qn . specific region is proportional to the length/area/volume of that region,
0.05
PDF
PDF
0.05
and where the density of occurrence in any one specific spot is constant
Chain Properties throughout the whole support.
0.00
0.00
A chain is irreducible if you can get from anywhere to anywhere. If a
chain (on a finite state space) is irreducible, then all of its states are
Normal Distribution 0 5 10
x
15 20 0 5 10
x
15 20
recurrent. A chain is periodic if any of its states are periodic, and is Let us say that X is distributed N (µ, σ 2 ). We know the following: Let us say that X is distributed Gamma(a, λ). We know the following:
aperiodic if none of its states are periodic. In an irreducible chain, all
Central Limit Theorem The Normal distribution is ubiquitous because
states have the same period. Story You sit waiting for shooting stars, where the waiting time for a star
of the Central Limit Theorem, which states that the sample mean of
is distributed Expo(λ). You want to see n shooting stars before you go
A chain is reversible with respect to ~ s if si qij = sj qji for all i, j. i.i.d. r.v.s will approach a Normal distribution as the sample size grows,
home. The total waiting time for the nth shooting star is Gamma(n, λ).
Examples of reversible chains include any chain with qij = qji , with regardless of the initial distribution.
1 1 1
s = ( M , M , . . . , M ), and random walk on an undirected network.
~ Location-Scale Transformation Every time we shift a Normal r.v. (by Example You are at a bank, and there are 3 people ahead of you. The
adding a constant) or rescale a Normal (by multiplying by a constant), we serving time for each person is Exponential with mean 2 minutes. Only one
change it to another Normal r.v. For any Normal X ∼ N (µ, σ 2 ), we can person at a time can be served. The distribution of your waiting time until
Stationary Distribution it’s your turn to be served is Gamma(3, 12 ).
transform it to the standard N (0, 1) by the following transformation:
Let us say that the vector ~ s = (s1 , s2 , . . . , sM ) be a PMF (written as a row X−µ
vector). We will call ~ s the stationary distribution for the chain if Z= ∼ N (0, 1) Beta Distribution
~
sQ = ~s. As a consequence, if Xt has the stationary distribution, then all σ
future Xt+1 , Xt+2 , . . . also have the stationary distribution. Standard Normal The Standard Normal, Z ∼ N (0, 1), has mean 0 and Beta(0.5, 0.5) Beta(2, 1)
2.0
5
variance 1. Its CDF is denoted by Φ.
For irreducible, aperiodic chains, the stationary distribution exists, is
1.5
unique, and si is the long-run probability of a chain being at state i. The
Exponential Distribution
3
PDF
PDF
1.0
expected number of steps to return to i starting from i is 1/si .
2
Let us say that X is distributed Expo(λ). We know the following:
0.5
To find the stationary distribution, you can solve the matrix equation
1
(Q0 − I)~
s 0 = 0. The stationary distribution is uniform if the columns of Q Story You’re sitting on an open meadow right before the break of dawn,
0.0
0
sum to 1. wishing that airplanes in the night sky were shooting stars, because you 0.0 0.2 0.4
x
0.6 0.8 1.0 0.0 0.2 0.4
x
0.6 0.8 1.0
could really use a wish right now. You know that shooting stars come on
Reversibility Condition Implies Stationarity If you have a PMF ~ s and average every 15 minutes, but a shooting star is not “due” to come just
Beta(2, 8) Beta(5, 5)
2.5
a Markov chain with transition matrix Q, then si qij = sj qji for all states because you’ve waited so long. Your waiting time is memoryless; the
2.0
i, j implies that ~
s is stationary. additional time until the next shooting star comes does not depend on how
1.5
long you’ve waited already.
2
PDF
PDF
Random Walk on an Undirected Network
1.0
Example The waiting time until the next shooting star is distributed
0.5
Expo(4) hours. Here λ = 4 is the rate parameter, since shooting stars
0.0
1
0
arrive at a rate of 1 per 1/4 hour on average. The expected time until the 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0
the number of “successes” we will have in a draw of n objects, without Xi ∼ Bin(n, pi ) since we can define “success” to mean category i. If you
0.25
●
replacement. The draw of n objects is assumed to be a simple random lump together multiple categories in a Multinomial, then it is still
0.20
● ●
sample (all sets of n objects are equally likely). Multinomial. For example, Xi + Xj ∼ Bin(n, pi + pj ) for i 6= j since we can
0.15
pmf
● ● Examples Here are some HGeom examples. define “success” to mean being in category i or j. Similarly, if k = 6 and we
0.10
● ●
Let’s say that we have only b Weedles (failure) and w Pikachus (X1 + X2 , X3 + X4 + X5 , X6 ) ∼ Mult3 (n, (p1 + p2 , p3 + p4 + p5 , p6 ))
0.00
● ●
● ●
(success) in Viridian Forest. We encounter n Pokemon in the forest,
0 2 4 6 8 10
and X is the number of Pikachus in our encounters. Conditioning on some Xj also still gives a Multinomial:
x
Let us say that X is distributed Bin(n, p). We know the following: The number of Aces in a 5 card hand.
p1 pk−1
X1 , . . . , Xk−1 |Xk = nk ∼ Multk−1 n − nk , ,...,
Story X is the number of “successes” that we will achieve in n You have w white balls and b black balls, and you draw n balls. You 1 − pk 1 − pk
independent trials, where each trial is either a success or a failure, each will draw X white balls.
with the same probability p of success. We can also write X as a sum of Variances and Covariances We have Xi ∼ Bin(n, pi ) marginally, so
multiple independent Bern(p) random variables. Let X ∼ Bin(n, p) and You have w white balls and b black balls, and you draw n balls Var(Xi ) = npi (1 − pi ). Also, Cov(Xi , Xj ) = −npi pj for i 6= j.
Xj ∼ Bern(p), where all of the Bernoullis are independent. Then without replacement. The number of white balls in your sample is
X = X1 + X2 + X3 + · · · + Xn
HGeom(w, b, n); the number of black balls is HGeom(b, w, n). Multivariate Uniform Distribution
Capture-recapture A forest has N elk, you capture n of them, tag See the univariate Uniform for stories and examples. For the 2D Uniform
Example If Jeremy Lin makes 10 free throws and each one independently them, and release them. Then you recapture a new sample of size m. on some region, probability is proportional to area. Every point in the
has a 43 chance of getting in, then the number of free throws he makes is How many tagged elk are now in the new sample? support has equal density, of value area of1 region . For the 3D Uniform,
distributed Bin(10, 34 ). HGeom(n, N − n, m) probability is proportional to volume.
Multivariate Normal (MVN) Distribution Formulas The table above gives R commands for working with various named
distributions. Commands analogous to pbinom, qbinom, and rbinom work for
~ = (X1 , X2 , . . . , Xk ) is Multivariate Normal if every linear
A vector X the other distributions in the table. For example, pnorm, qnorm, and rnorm
combination is Normally distributed, i.e., t1 X1 + t2 X2 + · · · + tk Xk is Geometric Series can be used to get the CDF, quantiles, and random generation for the
Normal for any constants t1 , t2 , . . . , tk . The parameters of the Multivariate Normal. For the Multinomial, dmultinom can be used for calculating the
n−1
Normal are the mean vector µ ~ = (µ1 , µ2 , . . . , µk ) and the covariance 2 n−1
X k 1 − rn joint PMF and rmultinom can be used for generating random vectors. For
matrix where the (i, j) entry is Cov(Xi , Xj ). 1 + r + r + ··· + r = r =
k=0
1−r the Multivariate Normal, after installing and loading the mvtnorm package
dmvnorm can be used for calculating the joint PDF and rmvnorm can be used
Properties The Multivariate Normal has the following properties. 2 1
1 + r + r + ··· = if |r| < 1 for generating random vectors.
1−r
Any subvector is also MVN.
If any two elements within an MVN are uncorrelated, then they are Exponential Function (ex ) Recommended Resources
independent. ∞ n 2 3 n
x
X x x x x
+ · · · = lim
The joint PDF of a Bivariate Normal (X, Y ) with N (0, 1) marginal
e =
n=0
n!
=1+x+
2!
+
3! n→∞
1+
n Introduction to Probability Book (http://bit.ly/introprobability)
distributions and correlation ρ ∈ (−1, 1) is
Gamma and Beta Integrals Stat 110 Online (http://stat110.net)
1 1
fX,Y (x, y) =
2πτ 2τ
2 2
exp − 2 (x + y − 2ρxy) , You can sometimes solve complicated-looking integrals by pattern-matching Stat 110 Quora Blog (https://stat110.quora.com/)
p to a gamma or beta integral: Quora Probability FAQ (http://bit.ly/probabilityfaq)
with τ = 1 − ρ2 . Z ∞
t−1 −x
Z 1
a−1 b−1 Γ(a)Γ(b) R Studio (https://www.rstudio.com)
x e dx = Γ(t) x (1 − x) dx =
0 0 Γ(a + b) LaTeX File (github.com/mynameisjanus/6431xProbability)
Distribution Properties
Also, Γ(a + 1) = aΓ(a), and Γ(n) = (n − 1)! if n is a positive integer.
Please share this cheatsheet with friends!
Important CDFs Euler’s Approximation for Harmonic Sums
Standard Normal Φ 1 1 1
1+ + + ··· + ≈ log n + 0.577 . . .
Exponential(λ) F (x) = 1 − e −λx
, for x ∈ (0, ∞) 2 3 n
Bernoulli P (X = 1) = p
Bern(p) P (X = 0) = q = 1 − p p pq q + pet
n k n−k
Binomial P (X = k) = k
p q
Bin(n, p) k ∈ {0, 1, 2, . . . n} np npq (q + pet )n
Geometric P (X = k) = q k p
p
Geom(p) k ∈ {0, 1, 2, . . . } q/p q/p2 1−qet
, qet < 1
r+n−1 r n
Negative Binomial P (X = n) = r−1
p q
p
NBin(r, p) n ∈ {0, 1, 2, . . . } rq/p rq/p2 ( 1−qe r t
t ) , qe < 1
w+b
P (X = k) = w b /
Hypergeometric k n−k n
nw w+b−n µ µ
HGeom(w, b, n) k ∈ {0, 1, 2, . . . , n} µ= b+w w+b−1
nn (1 − n
) messy
e−λ λk
Poisson P (X = k) = k!
t
Pois(λ) k ∈ {0, 1, 2, . . . } λ λ eλ(e −1)
1
Uniform f (x) = b−a
a+b (b−a)2 etb −eta
Unif(a, b) x ∈ (a, b) 2 12 t(b−a)
2 2
f (x) = √1 e−(x − µ) /(2σ )
Normal σ 2π
σ 2 t2
N (µ, σ 2 ) x ∈ (−∞, ∞) µ σ2 etµ+ 2
1
f (x) = Γ(a)
(λx)a e−λx x1
Gamma a
a a λ
Gamma(a, λ) x ∈ (0, ∞) λ λ2 λ−t
,t<λ
Γ(a+b) a−1
f (x) = Γ(a)Γ(b)
x (1 − x)b−1
Beta
a µ(1−µ)
Beta(a, b) x ∈ (0, 1) µ= a+b (a+b+1)
messy
2
1
√ e−(log x−µ) /(2σ 2 )
Log-Normal xσ 2π
2 2
LN (µ, σ 2 ) x ∈ (0, ∞) θ = eµ+σ /2 θ2 (eσ − 1) doesn’t exist
1
Chi-Square xn/2−1 e−x/2
2n/2 Γ(n/2)
χ2n x ∈ (0, ∞) n 2n (1 − 2t)−n/2 , t < 1/2
Γ((n+1)/2)
√
nπΓ(n/2)
(1 + x2 /n)−(n+1)/2
Student-t
n
tn x ∈ (−∞, ∞) 0 if n > 1 n−2
if n > 2 doesn’t exist