Docsity

Probability Theory: Random Variables, Distributions, and Independence, Assignments of Law

Toggle sidebar
bg1
Bayesian Reference Sheet
Guide to David Draper’s Stats 131 Course at UCSC
Last Updated January 14, 2021 by
Burleigh Charlton
Generated from Joe Blitzstein’s probability template
Counting
Multiplication Rule
cake
waffle
S
V
C
S
V
CS
V
C
cake
waffle
cake
waffle
cake
waffle
Let’s say we have a compound experiment (an experiment with
multiple components). If the 1st component has n1possible
outcomes, the 2nd component has n2possible outcomes, ..., and
the rth component has nrpossible outcomes, then overall there
are n1n2...nrpossibilities for the whole experiment.
Sampling Table
7
6
5
8
4
2
9
3
1
The sampling table gives the number of possible samples of size k
out of a population of size n, under various assumptions about
how the sample is collected.
Order Matters Not Matter
With Replacement nkn+k−1
k
Without Replacement n!
(n−k)! n
k
Naive Definition of Probability
If all outcomes are equally likely, the probability of an event A
happening is:
Pnaive(A) = number of outcomes favorable to A
number of outcomes
Thinking Conditionally
Independence
Independent Events Aand Bare independent if knowing
whether Aoccurred gives no information about whether B
occurred. More formally, Aand B(which have nonzero
probability) are independent if and only if one of the following
equivalent statements holds:
P(A∩B) = P(A)P(B)
P(A|B) = P(A)
P(B|A) = P(B)
Conditional Independence Aand Bare conditionally
independent given Cif P(A∩B|C) = P(A|C)P(B|C).
Conditional independence does not imply independence, and
independence does not imply conditional independence.
Unions, Intersections, and Complements
De Morgan’s Laws A useful identity that can make calculating
probabilities of unions easier by relating them to intersections, and
vice versa. Analogous results hold with more than two sets.
(A∪B)c=Ac∩Bc
(A∩B)c=Ac∪Bc
Joint, Marginal, and Conditional
Joint Probability P(A∩B) or P(A, B) – Probability of Aand
B.
Marginal (Unconditional) Probability P(A) – Probability of
A.
Conditional Probability P(A|B) = P(A, B )/P (B) –
Probability of A, given that Boccurred.
Conditional Probability is Probability P(A|B) is a
probability function for any fixed B. Any theorem that holds for
probability also holds for conditional probability.
Probability of an Intersection or Union
Intersections via Conditioning
P(A, B) = P(A)P(B|A)
P(A, B, C) = P(A)P(B|A)P(C|A, B )
Unions via Inclusion-Exclusion
P(A∪B) = P(A) + P(B)−P(A∩B)
P(A∪B∪C) = P(A) + P(B) + P(C)
−P(A∩B)−P(A∩C)−P(B∩C)
+P(A∩B∩C).
Simpson’s Paradox
Dr. Hibbert Dr. Nick
heart
band-aid
It is possible to have
P(A|B, C)< P(A|Bc, C ) and P(A|B, Cc)< P(A|Bc, Cc)
yet also P(A|B)> P (A|Bc).
Law of Total Probability (LOTP)
Let B1, B2, B3, ...Bnbe a partition of the sample space (i.e., they
are disjoint and their union is the entire sample space).
P(A) = P(A|B1)P(B1) + P(A|B2)P(B2) + ···+P(A|Bn)P(Bn)
P(A) = P(A∩B1) + P(A∩B2) + ···+P(A∩Bn)
For LOTP with extra conditioning, just add in another event
B!
P(A|B) = P(A|B1,B)P(B1|B) + ···+P(A|Bn,B)P(Bn|B)
P(A|B) = P(A∩B1|B) + P(A∩B2|B) + ···+P(A∩Bn|B)
Special case of LOTP with Band Bcas partition:
P(A) = P(A|B)P(B) + P(A|Bc)P(Bc)
P(A) = P(A∩B) + P(A∩Bc)
Bis often considered as the whole of the background knowledge,
represented as B=B1,B2,B3, ..., Bn
Bayes’ Rule
Bayes’ Rule, and with extra conditioning (just add in B)
P(A|B) = P(B|A)P(A)
P(B)
P(A|B, B) = P(B|A, B)P(A|B)
P(B|B)
We can also write
P(A|B, B) = P(A, B, B)
P(B, B)=P(B, B|A)P(A)
P(B, B)
Odds Form of Bayes’ Rule
P(A|B)
P(Ac|B)=P(B|A)
P(B|Ac)
P(A)
P(Ac)
The posterior odds of Aare the likelihood ratio times the prior
odds.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Probability Theory: Random Variables, Distributions, and Independence and more Assignments Law in PDF only on Docsity!

Bayesian Reference Sheet

Guide to David Draper’s Stats 131 Course at UCSC

Last Updated January 14, 2021 by Burleigh Charlton Generated from Joe Blitzstein’s probability template

Counting

Multiplication Rule

cake

waffl e

S

V

C

S

V

C S

V

C

cake waffle cake waffle cake waffle

Let’s say we have a compound experiment (an experiment with multiple components). If the 1st component has n 1 possible outcomes, the 2nd component has n 2 possible outcomes,... , and the rth component has nr possible outcomes, then overall there are n 1 n 2... nr possibilities for the whole experiment.

Sampling Table

7

6

5

8

4

2

9 3

1

The sampling table gives the number of possible samples of size k out of a population of size n, under various assumptions about how the sample is collected.

Order Matters Not Matter

With Replacement nk^

(n + k − 1

k

Without Replacement

n! (n − k)!

(n

k

Naive Definition of Probability

If all outcomes are equally likely, the probability of an event A happening is:

Pnaive(A) =

number of outcomes favorable to A number of outcomes

Thinking Conditionally

Independence

Independent Events A and B are independent if knowing whether A occurred gives no information about whether B

occurred. More formally, A and B (which have nonzero probability) are independent if and only if one of the following equivalent statements holds: P (A ∩ B) = P (A)P (B) P (A|B) = P (A) P (B|A) = P (B)

Conditional Independence A and B are conditionally independent given C if P (A ∩ B|C) = P (A|C)P (B|C). Conditional independence does not imply independence, and independence does not imply conditional independence.

Unions, Intersections, and Complements

De Morgan’s Laws A useful identity that can make calculating probabilities of unions easier by relating them to intersections, and vice versa. Analogous results hold with more than two sets. (A ∪ B)c^ = Ac^ ∩ Bc (A ∩ B)c^ = Ac^ ∪ Bc

Joint, Marginal, and Conditional

Joint Probability P (A ∩ B) or P (A, B) – Probability of A and B. Marginal (Unconditional) Probability P (A) – Probability of A. Conditional Probability P (A|B) = P (A, B)/P (B) – Probability of A, given that B occurred. Conditional Probability is Probability P (A|B) is a probability function for any fixed B. Any theorem that holds for probability also holds for conditional probability.

Probability of an Intersection or Union

Intersections via Conditioning P (A, B) = P (A)P (B|A) P (A, B, C) = P (A)P (B|A)P (C|A, B) Unions via Inclusion-Exclusion P (A ∪ B) = P (A) + P (B) − P (A ∩ B) P (A ∪ B ∪ C) = P (A) + P (B) + P (C) − P (A ∩ B) − P (A ∩ C) − P (B ∩ C)

  • P (A ∩ B ∩ C).

Simpson’s Paradox

Dr. Hibbert Dr. Nick

heart

band-aid

It is possible to have P (A | B, C) < P (A | Bc, C) and P (A | B, Cc) < P (A | Bc, Cc) yet also P (A | B) > P (A | Bc).

Law of Total Probability (LOTP)

Let B 1 , B 2 , B 3 , ...Bn be a partition of the sample space (i.e., they are disjoint and their union is the entire sample space).

P (A) = P (A|B 1 )P (B 1 ) + P (A|B 2 )P (B 2 ) + · · · + P (A|Bn)P (Bn) P (A) = P (A ∩ B 1 ) + P (A ∩ B 2 ) + · · · + P (A ∩ Bn)

For LOTP with extra conditioning, just add in another event B!

P (A|B) = P (A|B 1 , B)P (B 1 |B) + · · · + P (A|Bn, B)P (Bn|B) P (A|B) = P (A ∩ B 1 |B) + P (A ∩ B 2 |B) + · · · + P (A ∩ Bn|B)

Special case of LOTP with B and Bc^ as partition:

P (A) = P (A|B)P (B) + P (A|Bc)P (Bc) P (A) = P (A ∩ B) + P (A ∩ Bc)

B is often considered as the whole of the background knowledge, represented as B = B 1 , B 2 , B 3 , ..., Bn

Bayes’ Rule

Bayes’ Rule, and with extra conditioning (just add in B)

P (A|B) =
P (B|A)P (A)
P (B)
P (A|B, B) =
P (B|A, B)P (A|B)
P (B|B)

We can also write

P (A|B, B) =
P (A, B, B)
P (B, B)
P (B, B|A)P (A)
P (B, B)

Odds Form of Bayes’ Rule

P (A|B)

P (Ac|B)

P (B|A)

P (B|Ac)

P (A)

P (Ac)

The posterior odds of A are the likelihood ratio times the prior odds.

Random Variables and their Distributions

PMF, CDF, and Independence

Probability Mass Function (PMF) Gives the probability that a discrete random variable takes on the value x.

pX (x) = P (X = x)

0 1 2 3 4

x

pmf

l

l

l l

l

The PMF satisfies

pX (x) ≥ 0 and

x

pX (x) = 1

Cumulative Distribution Function (CDF) Gives the probability that a random variable is less than or equal to x.

FX (x) = P (X ≤ x)

0 1 2 3 4

x

cdf

l

l l

l l

l l

l l

l

The CDF is an non-decreasing, right-continuous function with

FX (x) → 0 as x → −∞ and FX (x) → 1 as x → ∞

Independence Intuitively, two random variables are independent if knowing the value of one gives no information about the other. Discrete r.v.s X and Y are independent if for all values of x and y

P (X = x, Y = y) = P (X = x)P (Y = y)

Expected Value and Indicators

Expected Value and Linearity

Expected Value (a.k.a. mean, expectation, or average) is a weighted average of the possible outcomes of our random variable. Mathematically, if x 1 , x 2 , x 3 ,... are all of the distinct possible values that X can take, the expected value of X is

E(X) =

i

xiP (X = xi)

X 3 2 6 10 1 1 5 4 ...

Y 4 2 8 23

  • 0 9 1 ...

X + Y 7 4 14 33

  • 1 14 5 ...

∑ xi + ∑ yi = ∑ ( xi + yi )

E ( X ) + E ( Y ) = E ( X + Y )

i= 1

n i= 1

n i= 1

n n^1 n^1 n^1

Linearity For any r.v.s X and Y , and constants a, b, c,

E(aX + bY + c) = aE(X) + bE(Y ) + c

Same distribution implies same mean If X and Y have the same distribution, then E(X) = E(Y ) and, more generally,

E(g(X)) = E(g(Y ))

Conditional Expected Value is defined like expectation, only conditioned on any event A.

E(X|A) =

x

xP (X = x|A)

Indicator Random Variables

Indicator Random Variable is a random variable that takes on the value 1 or 0. It is always an indicator of some event: if the event occurs, the indicator is 1; otherwise it is 0. They are useful for many problems about counting how many events of some kind occur. Write

IA =

1 if A occurs, 0 if A does not occur.

Note that I^2 A = IA, IAIB = IA∩B , and IA∪B = IA + IB − IAIB.

Distribution IA ∼ Bern(p) where p = P (A).

Fundamental Bridge The expectation of the indicator for event A is the probability of event A: E(IA) = P (A).

Variance and Standard Deviation

Var(X) = E (X − E(X))^2 = E(X^2 ) − (E(X))^2

SD(X) =

Var(X)

Continuous RVs, LOTUS, UoU

Continuous Random Variables (CRVs)

What’s the probability that a CRV is in an interval? Take the difference in CDF values (or use the PDF as described later). P (a ≤ X ≤ b) = P (X ≤ b) − P (X ≤ a) = FX (b) − FX (a)

For X ∼ N (μ, σ^2 ), this becomes

P (a ≤ X ≤ b) = Φ

b − μ σ

a − μ σ

What is the Probability Density Function (PDF)? The PDF f is the derivative of the CDF F. F ′(x) = f (x) A PDF is nonnegative and integrates to 1. By the fundamental theorem of calculus, to get from PDF back to CDF we can integrate:

F (x) =

∫ (^) x

−∞

f (t)dt

0.00−4 −2 0 2 4

x

PDF

0.0 −4 −2 0 2 4

0.^

x

CDF

To find the probability that a CRV takes on a value in an interval, integrate the PDF over that interval.

F (b) − F (a) =

∫ (^) b

a

f (x)dx

How do I find the expected value of a CRV? Analogous to the discrete case, where you sum x times the PMF, for CRVs you integrate x times the PDF.

E(X) =

−∞

xf (x)dx

LOTUS

Expected value of a function of an r.v. The expected value of X is defined this way:

E(X) =

x

xP (X = x) (for discrete X)

E(X) =

−∞

xf (x)dx (for continuous X)

The Law of the Unconscious Statistician (LOTUS) states that you can find the expected value of a function of a random variable, g(X), in a similar way, by replacing the x in front of the PMF/PDF by g(x) but still working with the PMF/PDF of X:

E(g(X)) =

x

g(x)P (X = x) (for discrete X)

E(g(X)) =

−∞

g(x)f (x)dx (for continuous X)

Covariance and Transformations

Covariance and Correlation

Covariance is the analog of variance for two random variables.

Cov(X, Y ) = E ((X − E(X))(Y − E(Y ))) = E(XY ) − E(X)E(Y )

Note that

Cov(X, X) = E(X^2 ) − (E(X))^2 = Var(X)

Correlation is a standardized version of covariance that is always between −1 and 1.

Corr(X, Y ) =

Cov(X, Y ) √ Var(X)Var(Y )

Covariance and Independence If two random variables are independent, then they are uncorrelated. The converse is not necessarily true (e.g., consider X ∼ N (0, 1) and Y = X^2 ).

X ⊥⊥ Y −→ Cov(X, Y ) = 0 −→ E(XY ) = E(X)E(Y )

Covariance and Variance The variance of a sum can be found by

Var(X + Y ) = Var(X) + Var(Y ) + 2Cov(X, Y )

Var(X 1 + X 2 + · · · + Xn) =

∑^ n

i=

Var(Xi) + 2

i<j

Cov(Xi, Xj )

If X and Y are independent then they have covariance 0, so

X ⊥⊥ Y =⇒ Var(X + Y ) = Var(X) + Var(Y )

If X 1 , X 2 ,... , Xn are identically distributed and have the same covariance relationships (often by symmetry), then

Var(X 1 + X 2 + · · · + Xn) = nVar(X 1 ) + 2

(n

2

Cov(X 1 , X 2 )

Covariance Properties For random variables W, X, Y, Z and constants a, b:

Cov(X, Y ) = Cov(Y, X) Cov(X + a, Y + b) = Cov(X, Y ) Cov(aX, bY ) = abCov(X, Y ) Cov(W + X, Y + Z) = Cov(W, Y ) + Cov(W, Z) + Cov(X, Y )

  • Cov(X, Z)

Correlation is location-invariant and scale-invariant For any constants a, b, c, d with a and c nonzero,

Corr(aX + b, cY + d) = Corr(X, Y )

Transformations

One Variable Transformations Let’s say that we have a random 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 and strictly increasing (or strictly decreasing), then the PDF of Y is

fY (y) = fX (x)

∣∣^ dx dy

∣∣ = fX (g−^1 (y))

∣∣^ d dy

g−^1 (y)

The derivative of the inverse transformation is called the Jacobian.

Two Variable Transformations Similarly, let’s say we know the joint PDF of U and V but are also interested in the random vector (X, Y ) defined by (X, Y ) = g(U, V ). Let

∂(u, v) ∂(x, y)

( (^) ∂u ∂x

∂u ∂y ∂v ∂x

∂v ∂y

be the Jacobian matrix. If the entries in this matrix exist and are continuous, and the determinant of the matrix is never 0, then

fX,Y (x, y) = fU,V (u, v)

∂(u, v) ∂(x, y)

The inner bars tells us to take the matrix’s determinant, and the outer bars tell us to take the absolute value. In a 2 × 2 matrix, ∣ ∣ ∣ ∣

a b c d

∣ =^ |ad^ −^ bc|

Convolutions

Convolution Integral If you want to find the PDF of the sum of two independent CRVs X and Y , you can do the following integral:

fX+Y (t) =

−∞

fX (x)fY (t − x)dx

Example Let X, Y ∼ N (0, 1) be i.i.d. Then for each fixed t,

fX+Y (t) =

−∞

2 π

e−x

2 π

e−(t−x)

(^2) / 2 dx

By completing the square and using the fact that a Normal PDF integrates to 1, this works out to fX+Y (t) being the N (0, 2) PDF.

Poisson Process

Definition We have a Poisson process of rate λ arrivals per unit time if the following conditions hold:

  1. The number of arrivals in a time interval of length t is Pois(λt).
  2. Numbers of arrivals in disjoint time intervals are independent.

For example, the numbers of arrivals in the time intervals [0, 5], (5, 12), and [13, 23) are independent with Pois(5λ), Pois(7λ), Pois(10λ) distributions, respectively.

0 T 1 T 2 T 3 T 4 T 5

**+ +

  • ++**

Count-Time Duality Consider a Poisson process of emails arriving in an inbox at rate λ emails per hour. Let Tn be the time of arrival of the nth 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 T 1. The event T 1 > t, the 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 first t hours. So

P (T 1 > t) = P (Nt = 0) = e−λt^ −→ P (T 1 ≤ t) = 1 − e−λt Thus we have T 1 ∼ Expo(λ). By the memoryless property and similar reasoning, the interarrival times between emails are i.i.d. Expo(λ), i.e., the differences Tn − Tn− 1 are i.i.d. Expo(λ).

Order Statistics

Definition Let’s say you have n i.i.d. r.v.s X 1 , X 2 ,... , Xn. If you arrange them from smallest to largest, the ith element in that list is the ith order statistic, denoted X(i). So X(1) is the smallest in the list and X(n) is the largest in the list.

Note that the order statistics are dependent, e.g., learning X(4) = 42 gives us the information that X(1), X(2), X(3) are ≤ 42 and X(5), X(6),... , X(n) are ≥ 42.

Distribution Taking n i.i.d. random variables X 1 , X 2 ,... , Xn with CDF F (x) and PDF f (x), the CDF and PDF of X(i) are:

FX(i) (x) = P (X(i) ≤ x) =

∑^ n

k=i

(n

k

F (x)k^ (1 − F (x))n−k

fX(i) (x) = n

(n − 1

i − 1

F (x)i−^1 (1 − F (x))n−if (x)

Uniform Order Statistics The jth order statistic of i.i.d. U 1 ,... , Un ∼ Unif(0, 1) is U(j) ∼ Beta(j, n − j + 1).

Conditional Expectation

Conditioning on an Event We can find E(Y |A), the expected value of Y given that event A occurred. A very important case is when A is the event X = x. Note that E(Y |A) is a number. For example:

ˆ The expected value of a fair die roll, given that it is prime, is 1 3 ·^ 2 +^

1 3 ·^ 3 +^

1 3 ·^ 5 =^

10

ˆ Let Y be the number of successes in 10 independent Bernoulli trials with probability p of success. Let A be the event that the first 3 trials are all successes. Then

E(Y |A) = 3 + 7p

since the number of successes among the last 7 trials is Bin(7, p).

ˆ Let T ∼ Expo(1/10) be how long you have to wait until the shuttle comes. Given that you have already waited t minutes, the expected additional waiting time is 10 more minutes, by the memoryless property. That is, E(T |T > t) = t + 10.

Discrete Y Continuous Y

E(Y ) =

∑ y yP^ (Y^ =^ y)^ E(Y^ ) =^

∫ (^) ∞ −∞ yfY^ (y)dy E(Y |A) =

∑ y yP^ (Y^ =^ y|A)^ E(Y^ |A) =^

∫ (^) ∞ −∞ yf^ (y|A)dy

Conditioning on a Random Variable We can also find E(Y |X), the expected value of Y given the random variable X. This is a function of the random variable X. It is not a number except in certain special cases such as if X ⊥⊥ Y. To find E(Y |X), find E(Y |X = x) and then plug in X for x. For example:

ˆ If E(Y |X = x) = x^3 + 5x, then E(Y |X) = X^3 + 5X. ˆ Let Y be the number of successes in 10 independent Bernoulli trials with probability p of success and X be the number of successes among the first 3 trials. Then E(Y |X) = X + 7p. ˆ Let X ∼ N (0, 1) and Y = X^2. Then E(Y |X = x) = x^2 since if we know X = x then we know Y = x^2. And E(X|Y = y) = 0 since if we know Y = y then we know X = ±

y, with equal probabilities (by symmetry). So E(Y |X) = X^2 , E(X|Y ) = 0.

Properties of Conditional Expectation

  1. E(Y |X) = E(Y ) if X ⊥⊥ Y
  2. E(h(X)W |X) = h(X)E(W |X) (taking out what’s known) In particular, E(h(X)|X) = h(X).
  3. E(E(Y |X)) = E(Y ) (Adam’s Law, a.k.a. Law of Total Expectation)

Adam’s Law (a.k.a. Law of Total Expectation) can also be written in a way that looks analogous to LOTP. For any events A 1 , A 2 ,... , An that partition the sample space,

E(Y ) = E(Y |A 1 )P (A 1 ) + · · · + E(Y |An)P (An)

For the special case where the partition is A, Ac, this says

E(Y ) = E(Y |A)P (A) + E(Y |Ac)P (Ac)

Eve’s Law (a.k.a. Law of Total Variance)

Var(Y ) = E(Var(Y |X)) + Var(E(Y |X))

MVN, LLN, CLT

Law of Large Numbers (LLN)

Let X 1 , X 2 , X 3... be i.i.d. with mean μ. The sample mean is

X¯n = X^1 +^ X^2 +^ X^3 +^ · · ·^ +^ Xn n

The Law of Large Numbers states that as n → ∞, X¯n → μ with probability 1. For example, in flips of a coin with probability p of Heads, let Xj be the indicator of the jth flip being Heads. Then LLN says the proportion of Heads converges to p (with probability 1).

Central Limit Theorem (CLT)

Approximation using CLT

We use ∼˙ to denote is approximately distributed. We can use the Central Limit Theorem to approximate the distribution of a random variable Y = X 1 + X 2 + · · · + Xn that is a sum of n i.i.d. random variables Xi. Let E(Y ) = μY and Var(Y ) = σ^2 Y. The CLT says Y ∼ N˙ (μY , σ Y^2 )

If the Xi are i.i.d. with mean μX and variance σ^2 X , then μY = nμX and σ Y^2 = nσ^2 X. For the sample mean X¯n, the CLT says

X¯n =^1 n

(X 1 + X 2 + · · · + Xn) ˙∼ N (μX , σ^2 X /n)

Asymptotic Distributions using CLT

We use −D→ to denote converges in distribution to as n → ∞. The CLT says that if we standardize the sum X 1 + · · · + Xn then the distribution of the sum converges to N (0, 1) as n → ∞:

1 σ

n

(X 1 + · · · + Xn − nμX ) −D→ N (0, 1)

In other words, the CDF of the left-hand side goes to the standard Normal CDF, Φ. In terms of the sample mean, the CLT says √ n( X¯n − μX ) σX

−D→ N (0, 1)

Markov Chains

Definition

(^1) 1/2^1 2 1/2 1/4 3

5/ 1/3 1/6 4

7/ 1/4 1/8 5

7/

A Markov chain is a random walk in a state space, which we will assume is finite, say { 1 , 2 ,... , M }. We let Xt denote which element of the state space the walk is visiting at time t. The Markov chain is the sequence of random variables tracking where the walk is at all points in time, X 0 , X 1 , X 2 ,.... By definition, a Markov chain must satisfy the Markov property, which says that if you want to predict where the chain will be at a future time, if we know the present state then the entire past history is irrelevant. Given the present, the past and future are conditionally independent. Symbolically,

P (Xn+1 = j|X 0 = i 0 , X 1 = i 1 ,... , Xn = i) = P (Xn+1 = j|Xn = i)

State Properties

A state is either recurrent or transient. ˆ If you start at a recurrent state, then you will always return back to that state at some point in the future. nYou can check-out any time you like, but you can never leave. n

ˆ Otherwise you are at a transient state. There is some positive probability that once you leave you will never return. nYou don’t have to go home, but you can’t stay here. n A state is either periodic or aperiodic. ˆ If you start at a periodic state of period k, then the GCD of the possible numbers of steps it would take to return back is k > 1.

ˆ Otherwise you are at an aperiodic state. The GCD of the possible numbers of steps it would take to return back is 1.

Transition Matrix

Let the state space be { 1 , 2 ,... , M }. The transition matrix Q is the M × M matrix where element qij is the probability that the chain goes from state i to state j in one step:

qij = P (Xn+1 = j|Xn = i)

To find the probability that the chain goes from state i to state j in exactly m steps, take the (i, j) element of Qm.

q

(m) ij =^ P^ (Xn+m^ =^ j|Xn^ =^ i)

If X 0 is distributed according to the row vector PMF ~p, i.e., pj = P (X 0 = j), then the PMF of Xn is ~pQn.

Chain Properties

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 recurrent. A chain is periodic if any of its states are periodic, and is aperiodic if none of its states are periodic. In an irreducible chain, all states have the same period.

A chain is reversible with respect to ~s if siqij = sj qji for all i, j. Examples of reversible chains include any chain with qij = qji, with ~s = ( (^) M^1 , (^) M^1 ,... , (^) M^1 ), and random walk on an undirected network.

Stationary Distribution

Let us say that the vector ~s = (s 1 , s 2 ,... , sM ) be a PMF (written as a row vector). We will call ~s the stationary distribution for the chain if ~sQ = ~s. As a consequence, if Xt has the stationary distribution, then all future Xt+1, Xt+2,... also have the stationary distribution. For irreducible, aperiodic chains, the stationary distribution exists, is unique, and si is the long-run probability of a chain being at state i. The expected number of steps to return to i starting from i is 1/si. To find the stationary distribution, you can solve the matrix equation (Q′^ − I)~s ′^ = 0. The stationary distribution is uniform if the columns of Q sum to 1. Reversibility Condition Implies Stationarity If you have a PMF ~s and a Markov chain with transition matrix Q, then siqij = sj qji for all states i, j implies that ~s is stationary.

Random Walk on an Undirected Network

4

3

1

2

5

If you have a collection of nodes, pairs of which can be connected by undirected edges, and a Markov chain is run by going from the current node to a uniformly random node that is connected to it by an edge, then this is a random walk on an undirected network. The stationary distribution of this chain is proportional to the degree sequence (this is the sequence of degrees, where the degree of a node is how many edges are attached to it). For example, the stationary distribution of random walk on the network shown above is proportional to (3, 3 , 2 , 4 , 2), so it’s ( 143 , 143 , 142 , 144 , 142 ).

Discrete Distributions

Distributions for four sampling schemes

Replace No Replace

Fixed # trials (n) Binomial HGeom (Bern if n = 1) Draw until r success NBin NHGeom (Geom if r = 1)

Bernoulli Distribution

The Bernoulli distribution is the simplest case of the Binomial distribution, where we only have one trial (n = 1). Let us say that X is distributed Bern(p). We know the following:

Story A trial is performed with probability p of “success”, and X is the indicator of success: 1 means success, 0 means failure.

Example Let X be the indicator of Heads for a fair coin toss. Then X ∼ Bern( 12 ). Also, 1 − X ∼ Bern( 12 ) is the indicator of Tails.

Binomial Distribution

0.00 0 2 4 6 8 10

x

pmf

l l

l

l

l

l l

l

l l (^) l 0 2 4 6 8 10

Bin(10,1/2)

Let us say that X is distributed Bin(n, p). We know the following:

Story X is the number of “successes” that we will achieve in n independent trials, where each trial is either a success or a failure, each with the same probability p of success. We can also write X as a sum of multiple independent Bern(p) random variables. Let X ∼ Bin(n, p) and Xj ∼ Bern(p), where all of the Bernoullis are independent. Then

X = X 1 + X 2 + X 3 + · · · + Xn

Example If Jeremy Lin makes 10 free throws and each one independently has a 34 chance of getting in, then the number of

free throws he makes is distributed Bin(10, 34 ).

Properties Let X ∼ Bin(n, p), Y ∼ Bin(m, p) with X ⊥⊥ Y.

ˆ Redefine success n − X ∼ Bin(n, 1 − p)

ˆ Sum X + Y ∼ Bin(n + m, p) ˆ Conditional X|(X + Y = r) ∼ HGeom(n, m, r)

ˆ Binomial-Poisson Relationship Bin(n, p) is approximately Pois(np) if p is small. ˆ Binomial-Normal Relationship Bin(n, p) is approximately N (np, np(1 − p)) if n is large and p is not near 0 or 1.

Geometric Distribution

Let us say that X is distributed Geom(p). We know the following: Story X is the number of “failures” that we will achieve before we achieve our first success. Our successes have probability p.

Example If each pokeball we throw has probability 101 to catch Mew, the number of failed pokeballs will be distributed Geom( 101 ).

First Success Distribution

Equivalent to the Geometric distribution, except that it includes the first success in the count. This is 1 more than the number of failures. If X ∼ FS(p) then E(X) = 1/p.

Negative Binomial Distribution

Let us say that X is distributed NBin(r, p). We know the following: Story X is the number of “failures” that we will have before we achieve our rth success. Our successes have probability p. Example Thundershock has 60% accuracy and can faint a wild Raticate in 3 hits. The number of misses before Pikachu faints Raticate with Thundershock is distributed NBin(3, 0 .6).

Hypergeometric Distribution

Let us say that X is distributed HGeom(w, b, n). We know the following: Story In a population of w desired objects and b undesired objects, X is the number of “successes” we will have in a draw of n objects, without replacement. The draw of n objects is assumed to be a simple random sample (all sets of n objects are equally likely).

Examples Here are some HGeom examples.

ˆ Let’s say that we have only b Weedles (failure) and w Pikachus (success) in Viridian Forest. We encounter n Pokemon in the forest, and X is the number of Pikachus in our encounters.

ˆ The number of Aces in a 5 card hand.

ˆ You have w white balls and b black balls, and you draw n balls. You will draw X white balls.

ˆ You have w white balls and b black balls, and you draw n balls without replacement. The number of white balls in your sample is HGeom(w, b, n); the number of black balls is HGeom(b, w, n).

ˆ Capture-recapture A forest has N elk, you capture n of them, tag them, and release them. Then you recapture a new sample of size m. How many tagged elk are now in the new sample? HGeom(n, N − n, m)

Poisson Distribution

Let us say that X is distributed Pois(λ). We know the following: Story There are rare events (low probability events) that occur many different ways (high possibilities of occurences) at an average rate of λ occurrences per unit space or time. The number of events that occur in that unit of space or time is X.

Example A certain busy intersection has an average of 2 accidents per month. Since an accident is a low probability event that can happen many different ways, it is reasonable to model the number of accidents in a month at that intersection as Pois(2). Then the number of accidents that happen in two months at that intersection is distributed Pois(4). Properties Let X ∼ Pois(λ 1 ) and Y ∼ Pois(λ 2 ), with X ⊥⊥ Y.

  1. Sum X + Y ∼ Pois(λ 1 + λ 2 )
  2. Conditional X|(X + Y = n) ∼ Bin

n, (^) λλ^1 1 +λ 2

  1. Chicken-egg If there are Z ∼ Pois(λ) items and we randomly and independently “accept” each item with probability p, then the number of accepted items Z 1 ∼ Pois(λp), and the number of rejected items Z 2 ∼ Pois(λ(1 − p)), and Z 1 ⊥⊥ Z 2.

Multivariate Distributions

Multinomial Distribution

Let us say that the vector X~ = (X 1 , X 2 , X 3 ,... , Xk ) ∼ Multk (n, ~p) where ~p = (p 1 , p 2 ,... , pk ). Story We have n items, which can fall into any one of the k buckets independently with the probabilities p~ = (p 1 , p 2 ,... , pk ). Example Let us assume that every year, 100 students in the Harry Potter Universe are randomly and independently sorted into one of four houses with equal probability. The number of people in each of the houses is distributed Mult 4 (100, ~p), where ~p = (0. 25 , 0. 25 , 0. 25 , 0 .25). Note that X 1 + X 2 + · · · + X 4 = 100, and they are dependent. Joint PMF For n = n 1 + n 2 + · · · + nk ,

P ( X~ = ~n) =

n! n 1 !n 2!... nk!

pn 1 1 pn 2 2... p

nk k

Marginal PMF, Lumping, and Conditionals Marginally, Xi ∼ Bin(n, pi) since we can define “success” to mean category i. If you lump together multiple categories in a Multinomial, then it is still Multinomial. For example, Xi + Xj ∼ Bin(n, pi + pj ) for i 6 = j since we can define “success” to mean being in category i or j. Similarly, if k = 6 and we lump categories 1-2 and lump categories 3-5, then

(X 1 + X 2 , X 3 + X 4 + X 5 , X 6 ) ∼ Mult 3 (n, (p 1 + p 2 , p 3 + p 4 + p 5 , p 6 ))

Conditioning on some Xj also still gives a Multinomial:

X 1 ,... , Xk− 1 |Xk = nk ∼ Multk− 1

n − nk ,

p 1 1 − pk

pk− 1 1 − pk

Variances and Covariances We have Xi ∼ Bin(n, pi) marginally, so Var(Xi) = npi(1 − pi). Also, Cov(Xi, Xj ) = −npipj for i 6 = j.

Multivariate Uniform Distribution

See the univariate Uniform for stories and examples. For the 2D Uniform on some region, probability is proportional to area. Every point in the support has equal density, of value (^) area of region^1. For the 3D Uniform, probability is proportional to volume.

Multivariate Normal (MVN) Distribution

A vector X~ = (X 1 , X 2 ,... , Xk ) is Multivariate Normal if every linear combination is Normally distributed, i.e., t 1 X 1 + t 2 X 2 + · · · + tk Xk is Normal for any constants t 1 , t 2 ,... , tk. The parameters of the Multivariate Normal are the mean vector ~μ = (μ 1 , μ 2 ,... , μk ) and the covariance matrix where the (i, j) entry is Cov(Xi, Xj ).

Properties The Multivariate Normal has the following properties.

ˆ Any subvector is also MVN.

ˆ If any two elements within an MVN are uncorrelated, then they are independent.

ˆ The joint PDF of a Bivariate Normal (X, Y ) with N (0, 1) marginal distributions and correlation ρ ∈ (− 1 , 1) is

fX,Y (x, y) =

2 πτ

exp

2 τ 2

(x^2 + y^2 − 2 ρxy)

with τ =

1 − ρ^2.

Distribution Properties

Important CDFs

Standard Normal Φ

Exponential(λ) F (x) = 1 − e−λx, for x ∈ (0, ∞)

Uniform(0,1) F (x) = x, for x ∈ (0, 1)

Convolutions of Random Variables

A convolution of n random variables is simply their sum. For the following results, let X and Y be independent.

  1. X ∼ Pois(λ 1 ), Y ∼ Pois(λ 2 ) −→ X + Y ∼ Pois(λ 1 + λ 2 )
  2. X ∼ Bin(n 1 , p), Y ∼ Bin(n 2 , p) −→ X + Y ∼ Bin(n 1 + n 2 , p). Bin(n, p) can be thought of as a sum of i.i.d. Bern(p) r.v.s.
  3. X ∼ Gamma(a 1 , λ), Y ∼ Gamma(a 2 , λ) −→ X + Y ∼ Gamma(a 1 + a 2 , λ). Gamma(n, λ) with n an integer can be thought of as a sum of i.i.d. Expo(λ) r.v.s.
  4. X ∼ NBin(r 1 , p), Y ∼ NBin(r 2 , p) −→ X + Y ∼ NBin(r 1 + r 2 , p). NBin(r, p) can be thought of as a sum of i.i.d. Geom(p) r.v.s.
  5. X ∼ N (μ 1 , σ 12 ), Y ∼ N (μ 2 , σ^22 ) −→ X + Y ∼ N (μ 1 + μ 2 , σ^21 + σ^22 )

Special Cases of Distributions

  1. Bin(1, p) ∼ Bern(p)
  2. Beta(1, 1) ∼ Unif(0, 1)
  3. Gamma(1, λ) ∼ Expo(λ)
  4. χ^2 n ∼ Gamma

( (^) n 2 ,^

1 2

  1. NBin(1, p) ∼ Geom(p)

Inequalities

  1. Cauchy-Schwarz |E(XY )| ≤
E(X^2 )E(Y 2 )
  1. Markov P (X ≥ a) ≤ E| aX |for a > 0
  2. Chebyshev P (|X − μ| ≥ a) ≤ σ

2 a^2 for E(X) = μ, Var(X) = σ^2

  1. Jensen E(g(X)) ≥ g(E(X)) for g convex; reverse if g is concave

Formulas

Geometric Series

1 + r + r^2 + · · · + rn−^1 =

n∑− 1

k=

rk^ =

1 − rn 1 − r

1 + r + r^2 + · · · =

1 − r

if |r| < 1

Exponential Function (ex)

ex^ =

∑^ ∞

n=

xn n!

= 1 + x +

x^2 2!

x^3 3!

  • · · · = lim n→∞

x n

)n

Gamma and Beta Integrals

You can sometimes solve complicated-looking integrals by pattern-matching to a gamma or beta integral: ∫ (^) ∞

0

xt−^1 e−x^ dx = Γ(t)

0

xa−^1 (1 − x)b−^1 dx =

Γ(a)Γ(b) Γ(a + b)

Also, Γ(a + 1) = aΓ(a), and Γ(n) = (n − 1)! if n is a positive integer.

Euler’s Approximation for Harmonic Sums

n

≈ log n + 0. 577...

Stirling’s Approximation for Factorials

n! ≈

2 πn

( (^) n

e

)n

Miscellaneous Definitions

Medians and Quantiles Let X have CDF F. Then X has median m if F (m) ≥ 0 .5 and P (X ≥ m) ≥ 0 .5. For X continuous, m satisfies F (m) = 1/2. In general, the ath quantile of X is min{x : F (x) ≥ a}; the median is the case a = 1/2.

log Statisticians generally use log to refer to natural log (i.e., base e).

i.i.d r.v.s Independent, identically-distributed random variables.

Example Problems

Calculating Probability

ˆ A textbook has n typos, which are randomly scattered amongst its n pages, independently. You pick a random page. What is the probability that it has no typos? Answer: There is a

1 − (^1) n

probability that any specific

typo isn’t on your page, and thus a

n

)n probability

that there are no typos on your page. For n large, this is approximately e−^1 = 1/e. ˆ A monkey is pecking at a typewriter, producing each character independently and uniformly at random from the 26 letters of the English alphabet. Is it more likely to type the word EARTH or HEART first? (“Word” here means “contiguous substring of its typing output”.) Answer: HEART ˆ I roll a standard six-sided die (uniform distribution over 1-6) until I get 6. What’s the expected number of rolls I made, conditioned on the event that all rolls were even numbers? How about the general case with a die of 2n sides. Answer: For a dice with 2n sides, the expectation is 2n/(n+1)

Linearity and Indicators (1)

In a group of n people, what is the expected number of distinct birthdays (month and day)? What is the expected number of birthday matches? Answer: Let X be the number of distinct birthdays and Ij be the indicator for the jth day being represented.

E(Ij ) = 1 − P (no one born on day j) = 1 − (364/365)n

By linearity, E(X) = 365 (1 − (364/365)n). Now let Y be the number of birthday matches and Ji be the indicator that the ith pair of people have the same birthday. The probability that any two specific people share a birthday is 1/365, so

E(Y ) =

(n

2

Linearity and Indicators (2)

This problem is commonly known as the hat-matching problem. There are n people at a party, each with hat. At the end of the party, they each leave with a random hat. What is the expected number of people who leave with the right hat? Answer: Each hat has a 1/n chance of going to the right person. By linearity, the average number of hats that go to their owners is n(1/n) = 1.

Linearity and First Success

This problem is commonly known as the coupon collector problem. There are n coupon types. At each draw, you get a uniformly random coupon type. What is the expected number of coupons needed until you have a complete set? Answer: Let N be the number of coupons needed; we want E(N ). Let N = N 1 + · · · + Nn, where N 1 is the draws to get our

Problem-Solving Strategies

  1. Getting started. Start by defining relevant events and random variables. (“Let A be the event that I pick the fair coin”; “Let X be the number of successes.”) Clear notion is important for clear thinking! Then decide what it is that you’re supposed to be finding, in terms of your notation (“I want to find P (X = 3|A)”). Think about what type of object your answer should be (a number? A random variable? A PMF? A PDF?) and what it should be in terms of. Try simple and extreme cases. To make an abstract experiment more concrete, try drawing a picture or making up numbers that could have happened. Pattern recognition: does the structure of the problem resemble something we’ve seen before?
  2. Calculating probability of an event. Use counting principles if the naive definition of probability applies. Is the probability of the complement easier to find? Look for symmetries. Look for something to condition on, then apply Bayes’ Rule or the Law of Total Probability.
  3. Finding the distribution of a random variable. First make sure you need the full distribution not just the mean (see next item). Check the support of the random variable: what values can it take on? Use this to rule out distributions that don’t fit. Is there a story for one of the named distributions that fits the problem at hand? Can you write the random variable as a function of an r.v. with a known distribution, say Y = g(X)?
  4. Calculating expectation. If it has a named distribution, check out the table of distributions. If it’s a function of an r.v. with a named distribution, try LOTUS. If it’s a count of something, try breaking it up into indicator r.v.s. If you can condition on something natural, consider using Adam’s law.
  5. Calculating variance. Consider independence, named distributions, and LOTUS. If it’s a count of something, break it up into a sum of indicator r.v.s. If it’s a sum, use properties of covariance. If you can condition on something natural, consider using Eve’s Law.
  6. Calculating E(X^2 ). Do you already know E(X) or Var(X)? Recall that Var(X) = E(X^2 ) − (E(X))^2. Otherwise try LOTUS.
  7. Calculating covariance. Use the properties of covariance. If you’re trying to find the covariance between two components of a Multinomial distribution, Xi, Xj , then the covariance is −npipj for i 6 = j.
  8. Symmetry. If X 1 ,... , Xn are i.i.d., consider using symmetry.
  9. Calculating probabilities of orderings. Remember that all n! ordering of i.i.d. continuous random variables X 1 ,... , Xn are equally likely.
  10. Determining independence. There are several equivalent definitions. Think about simple and extreme cases to see if you can find a counterexample.
  11. Do a painful integral. If your integral looks painful, see if you can write your integral in terms of a known PDF (like Gamma or Beta), and use the fact that PDFs integrate to 1?
  12. Before moving on. Check some simple and extreme cases, check whether the answer seems plausible, check for biohazards.

Biohazards

  1. Don’t misuse the naive definition of probability. When answering “What is the probability that in a group of 3 people, no two have the same birth month?”, it is not correct to treat the people as indistinguishable balls being placed into 12 boxes, since that assumes the list of birth months {January, January, January} is just as likely as the list {January, April, June}, even though the latter is six times more likely.
  2. Don’t confuse unconditional, conditional, and joint probabilities. In applying P (A|B) = P^ (B P|A (B)P)^ (A), it is not correct to say “P (B) = 1 because we know B happened”; P (B) is the prior probability of B. Don’t confuse P (A|B) with P (A, B).
  3. Don’t assume independence without justification. In the matching problem, the probability that card 1 is a match and card 2 is a match is not 1/n^2. Binomial and Hypergeometric are often confused; the trials are independent in the Binomial story and dependent in the Hypergeometric story.
  4. Don’t forget to do sanity checks. Probabilities must be between 0 and 1. Variances must be ≥ 0. Supports must make sense. PMFs must sum to 1. PDFs must integrate to
  5. Don’t confuse random variables, numbers, and events. Let X be an r.v. Then g(X) is an r.v. for any function g. In particular, X^2 , |X|, F (X), and IX> 3 are r.v.s. P (X^2 < X|X ≥ 0), E(X), Var(X), and g(E(X)) are numbers. X = 2 and F (X) ≥ −1 are events. It does not make sense to write

−∞ F^ (X)dx, because^ F^ (X) is a random variable. It does not make sense to write P (X), because X is not an event.

  1. Don’t confuse a random variable with its distribution. To get the PDF of X^2 , you can’t just square the PDF of X. The right way is to use transformations. To get the PDF of X + Y , you can’t just add the PDF of X and the PDF of Y. The right way is to compute the convolution.
  2. Don’t pull non-linear functions out of expectations. E(g(X)) does not equal g(E(X)) in general. The St. Petersburg paradox is an extreme example. See also Jensen’s inequality. The right way to find E(g(X)) is with LOTUS.

Distributions in R

Command What it does help(distributions) shows documentation on distributions dbinom(k,n,p) PMF P (X = k) for X ∼ Bin(n, p) pbinom(x,n,p) CDF P (X ≤ x) for X ∼ Bin(n, p) qbinom(a,n,p) ath quantile for X ∼ Bin(n, p) rbinom(r,n,p) vector of r i.i.d. Bin(n, p) r.v.s dgeom(k,p) PMF P (X = k) for X ∼ Geom(p) dhyper(k,w,b,n) PMF P (X = k) for X ∼ HGeom(w, b, n) dnbinom(k,r,p) PMF P (X = k) for X ∼ NBin(r, p) dpois(k,r) PMF P (X = k) for X ∼ Pois(r) dbeta(x,a,b) PDF f (x) for X ∼ Beta(a, b) dchisq(x,n) PDF f (x) for X ∼ χ^2 n dexp(x,b) PDF f (x) for X ∼ Expo(b) dgamma(x,a,r) PDF f (x) for X ∼ Gamma(a, r) dlnorm(x,m,s) PDF f (x) for X ∼ LN (m, s^2 ) dnorm(x,m,s) PDF f (x) for X ∼ N (m, s^2 ) dt(x,n) PDF f (x) for X ∼ tn dunif(x,a,b) PDF f (x) for X ∼ Unif(a, b)

The table above gives R commands for working with various named distributions. Commands analogous to pbinom, qbinom, and rbinom work for the other distributions in the table. For example, pnorm, qnorm, and rnorm can be used to get the CDF, quantiles, and random generation for the Normal. For the Multinomial, dmultinom can be used for calculating the joint PMF and rmultinom can be used for generating random vectors. For the Multivariate Normal, after installing and loading the mvtnorm package dmvnorm can be used for calculating the joint PDF and rmvnorm can be used for generating random vectors.

Recommended Resources

ˆ Introduction to Probability Book (http://bit.ly/introprobability) ˆ Quora Probability FAQ (http://bit.ly/probabilityfaq)

ˆ R Studio (https://www.rstudio.com)

Further Reading

ˆ Real Analysis and Probability, Richard Dudley ˆ Probability, Albert Shiryaev

ˆ A Course in Probability Theory, Kai Lai Chung ˆ Probability Theory, S. R. S. Varadhan ˆ Stochastic Processes, S. R. S. Varadhan