Markov Processes & Markov Chains
Source: Unit 3 §11
From IID to dependence
A random sample is a sequence of IID random variables: independent and identically distributed.
- Identically distributed - no trends over the sequence; every draw comes from the same distribution.
- Independent -
P(X=a, Y=b) = P(X=a)·P(Y=b); the samples are not connected to each other.
Drawing balls from an urn with replacement is IID. Drawing without replacement is not: the distribution is the same each time, but the draws are dependent.
It often fails outright. If it has rained for the last 48 hours, today is more likely to be rainy - one feature's value affects another. When that happens you need a model with finite-state-machine-like structure, not a product of independent terms.
Random variables become random processes
- The domain of a random variable is its set of possible outcomes. A die has domain
{1, …, 6}withP = 1/6each. - Random variables are discrete or continuous - tomorrow's stock price lives in .
- A random process is a set of random variables over time, such as the stock price at each hour. All of them share the same domain.
- A deterministic process has its state fully determined by the initial conditions and the parameters - a dropped ball.
- A stochastic process has a state that cannot be determined even given the initial conditions and parameters.
The Markov property
A stochastic process is a Markov process if the next state depends only on the current state, not on the history. Such systems are memoryless: the future depends only on the present.
That is the first-order Markov property. An n-th order Markov process conditions the next state on the previous states.
- No single defined start state - the chain can start from any state, which is why a starting distribution is part of the model.
- It is irreducible if any state is reachable from any other.
- State
jis accessible fromiif there exists somen ≥ 0for which the probability of reachingjfromiinnsteps is nonzero.
Graphical representation and parameters
In a probabilistic graphical model, nodes are random variables and edges are conditional probability distributions between them, so the graph shows the causal relationships directly.
Pis the vector of starting probabilities, since the chain can begin in any state.aᵢⱼis the transition probability of moving from stateito statej.- Constraint: the sum of all transition probabilities out of a state is 1.
- All the transitions together form the transition matrix
A.
| From \ To | S | C | R |
|---|---|---|---|
| S | a₁₁ | a₁₂ | a₁₃ |
| C | a₂₁ | a₂₂ | a₂₃ |
| R | a₃₁ | a₃₂ | a₃₃ |
Each row of is a probability distribution over next states and therefore sums to 1. Columns do not sum to anything in particular. Transposing the matrix by accident is the single most common way to get a Markov question wrong.
Worked example 1: the probability of a weather sequence
Three states, {Sunny, Cloudy, Rainy}, with this transition matrix:
| From \ To | S | C | R |
|---|---|---|---|
| S | 0.6 | 0.2 | 0.2 |
| C | 0.2 | 0.5 | 0.3 |
| R | 0.1 | 0.4 | 0.5 |
Question: what is the probability of the sequence C, S, R, C, R, given that the chain starts in Cloudy with ?
- Start: .
- C → S is row C, column S: .
- S → R is row S, column R: .
- R → C is row R, column C: .
- C → R is row C, column R: .
- Multiply: .
Worked example 2: estimating the parameters from a trellis
Given an observed sequence over 14 days, estimate the model rather than being handed it.
- Starting probabilities are the frequency of each state appearing as a starting state.
- Transition matrix: count the transitions
i → j, then divide by the total number of transitions out ofi. - Dividing by the out-degree total, rather than by the grand total, is what keeps each row summing to 1.