Skip to content
LeetQuant
QR02 Advanced Probability and Stochastic Processes

QR02 · Advanced Probability and Stochastic Processes · Lesson 4 of 4

Markov Processes in Continuous Time

The Poisson process and its memorylessness, superposition and thinning; continuous-time Markov chains through generator matrices, holding times and stationary distributions; and the Ornstein–Uhlenbeck process as a mean-reverting continuous-state example.

20 min

Objective

Model things that change at random times rather than at fixed steps: order arrivals, defaults, regime switches, a spread that keeps being pulled back to its mean. The organising idea is the Markov property in continuous time: the future depends on the present state only, not on how long you have been in it. For jump processes that forces waiting times to be exponential.

The exponential and memorylessness

T∼Exp(λ)T \sim \text{Exp}(\lambda) has P(T>t)=e−λtP(T > t) = e^{-\lambda t}, mean 1/λ1/\lambda, and

P(T>s+t∣T>s)=e−λ(s+t)e−λs=e−λt=P(T>t).P(T > s + t \mid T > s) = \frac{e^{-\lambda(s + t)}}{e^{-\lambda s}} = e^{-\lambda t} = P(T > t).

Having waited ss tells you nothing about the remaining wait. The exponential is the only continuous distribution with this property, which is why it appears whenever a process "forgets" its history. Two facts used constantly: for independent Ti∼Exp(λi)T_i \sim \text{Exp}(\lambda_i), min⁡iTi∼Exp(∑iλi)\min_i T_i \sim \text{Exp}(\sum_i \lambda_i) and P(Tj is the minimum)=λj/∑iλiP(T_j \text{ is the minimum}) = \lambda_j / \sum_i \lambda_i.

The Poisson process

A Poisson process N(t)N(t) with rate λ\lambda counts events such that:

  1. N(0)=0N(0) = 0, and counts over disjoint intervals are independent.
  2. N(t+h)−N(t)∼Poisson(λh)N(t + h) - N(t) \sim \text{Poisson}(\lambda h).

Equivalently, the gaps between events are i.i.d. Exp(λ)\text{Exp}(\lambda). The two descriptions are linked by P(first event after t)=P(N(t)=0)=e−λtP(\text{first event after } t) = P(N(t) = 0) = e^{-\lambda t}, and the time of the nn-th event is Gamma(n,λ)(n, \lambda).

Operations that keep you inside the family:

  • Superposition. Independent Poisson processes with rates λ\lambda and μ\mu merge into a Poisson process of rate λ+μ\lambda + \mu, and each event independently comes from the first with probability λ/(λ+μ)\lambda/(\lambda + \mu).
  • Thinning. Keep each event independently with probability pp. The kept events form a Poisson process of rate λp\lambda p, the discarded ones a Poisson process of rate λ(1−p)\lambda(1 - p), and the two are independent.
  • Conditional uniformity. Given N(t)=nN(t) = n, the event times are distributed as nn i.i.d. Uniform(0,t)(0, t) points, sorted. The rate drops out.

Worked example

buy and sell orders

Buy orders arrive as a Poisson process at 3 per minute and sell orders independently at 2 per minute. 10% of buy orders are large, independently of everything else.

  1. What is the probability the next order is a buy, and the expected time until it?
  2. What is the probability at least two buys arrive before the first sell?
  3. What is the probability of no orders at all in the next 30 seconds?
  4. What is the probability of no large buy in the next 10 minutes?
Show solution
  1. All orders form a Poisson process of rate 3+2=53 + 2 = 5 per minute. The next one is a buy with probability 3/5=0.63/5 = 0.6, and it arrives after an Exp(5)\text{Exp}(5) wait with mean 1/51/5 minute =12= 12 seconds.
  2. Each order is independently a buy with probability 0.60.6, so we need the first two orders to be buys: 0.62=0.360.6^2 = 0.36.
  3. N(0.5)∼Poisson(5×0.5)N(0.5) \sim \text{Poisson}(5 \times 0.5), so P(N=0)=e−2.5≈0.082P(N = 0) = e^{-2.5} \approx 0.082.
  4. By thinning, large buys form a Poisson process of rate 0.30.3 per minute. Over 10 minutes the count is Poisson(3)(3), so the probability is e−3≈0.050e^{-3} \approx 0.050.

Each step reduced to a single fact (superposition, competing exponentials, the Poisson count, thinning). Name the fact out loud before computing.

Continuous-time Markov chains

A continuous-time Markov chain (CTMC) on a finite state space is specified by a generator (rate) matrix QQ:

  • qij≥0q_{ij} \ge 0 for i≠ji \ne j is the rate of jumping from ii to jj;
  • the diagonal is qii=−qiq_{ii} = -q_i with qi=∑j≠iqijq_i = \sum_{j \ne i} q_{ij}, so every row sums to zero.

The dynamics, read straight from QQ:

  • Holding time. In state ii the chain waits an Exp(qi)\text{Exp}(q_i) time, as the minimum of competing exponential clocks of rates qijq_{ij}.
  • Jump. It then moves to jj with probability qij/qiq_{ij}/q_i. These probabilities form the embedded jump chain, a discrete-time Markov chain.
  • Transition probabilities. P(t)ij=P(Xt=j∣X0=i)P(t)_{ij} = P(X_t = j \mid X_0 = i) satisfies P′(t)=P(t)QP'(t) = P(t)Q (the forward equation), so P(t)=etQP(t) = e^{tQ}. Over a short interval, P(Xt+h=j∣Xt=i)≈qijhP(X_{t+h} = j \mid X_t = i) \approx q_{ij}h.

A stationary distribution solves πQ=0\pi Q = 0 with ∑iπi=1\sum_i \pi_i = 1. Row by row this is global balance: the rate of probability flowing out of state jj, πjqj\pi_j q_j, equals the rate flowing in, ∑i≠jπiqij\sum_{i \ne j} \pi_i q_{ij}. For an irreducible finite chain π\pi is unique, P(t)→P(t) \to rows of π\pi, and πi\pi_i is the long-run fraction of time in ii. There is no periodicity problem in continuous time.

For two states with rates aa (1→21 \to 2) and bb (2→12 \to 1),

π1=ba+b,P11(t)=ba+b+aa+b e−(a+b)t,\pi_1 = \frac{b}{a + b}, \qquad P_{11}(t) = \frac{b}{a + b} + \frac{a}{a + b}\,e^{-(a + b)t},

so the chain forgets its start at rate a+ba + b, the non-zero eigenvalue of −Q-Q.

Jump chain versus time. The stationary distribution π~\tilde\pi of the jump chain counts visits, not time. Time fractions weight visits by mean holding times: πi∝π~i/qi\pi_i \propto \tilde\pi_i / q_i. A state visited often but left quickly can hold little of the time.

Worked example

a three-regime market

A market moves between Calm (C), Stressed (S) and Crisis (K), with rates per year

Q=(−2204−5130−3)Q = \begin{pmatrix} -2 & 2 & 0 \\ 4 & -5 & 1 \\ 3 & 0 & -3 \end{pmatrix}

(rows and columns ordered C, S, K). Find the long-run fraction of time in each regime, the expected time to the first crisis starting from Calm, and check your answer against the jump chain.

Show solution

Stationary distribution. The columns of πQ=0\pi Q = 0 give

  • S: 2πC−5πS=02\pi_C - 5\pi_S = 0, so πS=0.4 πC\pi_S = 0.4\,\pi_C;
  • K: πS−3πK=0\pi_S - 3\pi_K = 0, so πK=πS/3=215πC\pi_K = \pi_S/3 = \tfrac{2}{15}\pi_C.

Normalising, πC(1+615+215)=1\pi_C(1 + \tfrac{6}{15} + \tfrac{2}{15}) = 1, so π=(1523, 623, 223)≈(0.652, 0.261, 0.087)\pi = (\tfrac{15}{23},\ \tfrac{6}{23},\ \tfrac{2}{23}) \approx (0.652,\ 0.261,\ 0.087). The C column checks: −2⋅15+4⋅6+3⋅2=0-2 \cdot 15 + 4 \cdot 6 + 3 \cdot 2 = 0.

Flow check. Crises start at long-run rate πS×1=623\pi_S \times 1 = \tfrac{6}{23} per year and last 13\tfrac13 year on average, so the time fraction in crisis is 623⋅13=223\tfrac{6}{23} \cdot \tfrac13 = \tfrac{2}{23}. Consistent.

Time to crisis. Let hih_i be the expected time to reach K from ii. Each equation is "mean holding time plus where you go next":

hC=12+hS,hS=15+45hC.h_C = \tfrac12 + h_S, \qquad h_S = \tfrac15 + \tfrac45 h_C.

Substituting, hC=0.7+0.8 hCh_C = 0.7 + 0.8\,h_C, so hC=3.5h_C = 3.5 years (and hS=3h_S = 3).

Jump chain. Its transition probabilities are C →\to S with probability 1, S →\to C with 0.80.8 and S →\to K with 0.20.2, K →\to C with 1. Its stationary distribution is π~=(511, 511, 111)\tilde\pi = (\tfrac{5}{11},\ \tfrac{5}{11},\ \tfrac{1}{11}): Calm and Stressed are visited equally often. Weighting by mean holding times (12,15,13)(\tfrac12, \tfrac15, \tfrac13) gives (522, 111, 133)(\tfrac{5}{22},\ \tfrac{1}{11},\ \tfrac{1}{33}), which normalises to (1523, 623, 223)(\tfrac{15}{23},\ \tfrac{6}{23},\ \tfrac{2}{23}) again. Stressed spells are as frequent as calm ones but much shorter.

Simulating a CTMC

The holding-time and jump description is also the simulation algorithm (often called Gillespie's algorithm): draw an exponential holding time with the total exit rate, then pick the destination in proportion to its rate.

import random

rates = {"C": {"S": 2.0}, "S": {"C": 4.0, "K": 1.0}, "K": {"C": 3.0}}

def time_fractions(start="C", horizon=100_000.0, seed=1):
    rng = random.Random(seed)
    state, t = start, 0.0
    occupied = {s: 0.0 for s in rates}
    while t < horizon:
        out = rates[state]
        total = sum(out.values())
        hold = min(rng.expovariate(total), horizon - t)  # Exp(total) holding time
        occupied[state] += hold
        t += hold
        u, acc = rng.random() * total, 0.0  # jump to j with prob q_ij / q_i
        for nxt, q in out.items():
            acc += q
            if u < acc:
                state = nxt
                break
    return {s: round(v / horizon, 3) for s, v in occupied.items()}

print(time_fractions())  # {'C': 0.651, 'S': 0.262, 'K': 0.087}

The simulated fractions match (0.652,0.261,0.087)(0.652, 0.261, 0.087) to within Monte Carlo error.

A continuous-state example: Ornstein–Uhlenbeck

Not every Markov process jumps. The Ornstein–Uhlenbeck (OU) process moves continuously and is pulled towards a level μ\mu:

dXt=θ(μ−Xt) dt+σ dWt,θ>0.dX_t = \theta(\mu - X_t)\,dt + \sigma\,dW_t, \qquad \theta > 0.

Intuitively, over a short step the process drifts back towards μ\mu at a speed proportional to its distance from it, and receives a Brownian shock. It is Markov (the next move depends only on the current value) and Gaussian, with

Xt∣X0=x0∼N ⁣(μ+(x0−μ)e−θt,  σ22θ(1−e−2θt)).X_t \mid X_0 = x_0 \sim N\!\left(\mu + (x_0 - \mu)e^{-\theta t},\ \ \frac{\sigma^2}{2\theta}\big(1 - e^{-2\theta t}\big)\right).
  • The expected gap from μ\mu decays exponentially, with half-life ln⁡2/θ\ln 2/\theta.
  • As t→∞t \to \infty the law settles to the stationary distribution N(μ, σ2/(2θ))N(\mu,\ \sigma^2/(2\theta)): reversion strength and noise balance.
  • Sampled every Δ\Delta, it is exactly an AR(1): Xt+Δ−μ=ϕ(Xt−μ)+εX_{t+\Delta} - \mu = \phi(X_t - \mu) + \varepsilon with ϕ=e−θΔ\phi = e^{-\theta\Delta} and Var⁡(ε)=σ2(1−ϕ2)/(2θ)\operatorname{Var}(\varepsilon) = \sigma^2(1 - \phi^2)/(2\theta). Fitting an AR(1) to daily data and reading off ϕ\phi is how you estimate θ\theta in practice.

OU is the standard toy model for pairs-trading spreads, short rates (Vasicek) and the log of volatility. Its weaknesses: it can go negative, the reversion speed is assumed constant, and estimates of θ\theta from short samples are noisy and biased towards faster reversion.

Worked example

a mean-reverting spread

A spread follows an OU process with μ=0\mu = 0, half-life 5 trading days and σ=1\sigma = 1 per square-root day. It is currently at 4. Find its stationary standard deviation, its distribution in 5 days, and the probability it is below zero then.

Show solution

Reversion speed. θ=ln⁡2/5≈0.1386\theta = \ln 2 / 5 \approx 0.1386 per day.

Stationary spread. σ2/(2θ)=1/0.2773≈3.607\sigma^2/(2\theta) = 1/0.2773 \approx 3.607, so the stationary standard deviation is about 1.901.90. A reading of 4 is about 2.12.1 stationary standard deviations out.

In 5 days. The mean halves: 4e−5θ=24e^{-5\theta} = 2. The variance is 3.607×(1−e−10θ)=3.607×(1−14)≈2.7053.607 \times (1 - e^{-10\theta}) = 3.607 \times (1 - \tfrac14) \approx 2.705, a standard deviation of about 1.6451.645.

Crossing zero. P(X5<0)=Φ(−2/1.645)=Φ(−1.216)≈0.112P(X_5 < 0) = \Phi(-2/1.645) = \Phi(-1.216) \approx 0.112.

So even with a 5-day half-life, the spread has only about an 11% chance of having crossed back through its mean in 5 days: the expected gap halves, but the noise accumulated over 5 days is comparable to the remaining gap. The daily AR(1) coefficient is ϕ=e−θ≈0.871\phi = e^{-\theta} \approx 0.871.

Knowledge check

Buses arrive as a Poisson process at 4 per hour. You have already waited 20 minutes. What is your expected additional wait?

Knowledge check

A Poisson process of rate λ\lambda has exactly 3 events in [0,1][0, 1]. What is the probability that all three occurred in [0,12][0, \tfrac12]?

Knowledge check

A two-state CTMC's jump chain simply alternates, so it visits each state equally often. The holding rate is 1 in state A and 3 in state B. What long-run fraction of time is spent in A?

Knowledge check

An OU process has reversion speed θ=0.1\theta = 0.1 per day. What is the half-life of a deviation from the mean?

Key takeaways

  • Continuous-time jump processes that forget their past have exponential holding times; competing exponentials give the minimum rate ∑λi\sum \lambda_i and winner probabilities λj/∑λi\lambda_j/\sum \lambda_i.
  • Poisson processes are closed under superposition and thinning, and given the count, event times are uniform.
  • A CTMC is a generator QQ with rows summing to zero: hold Exp(qi)\text{Exp}(q_i), jump with probabilities qij/qiq_{ij}/q_i, P(t)=etQP(t) = e^{tQ}.
  • Stationary distributions solve πQ=0\pi Q = 0 and give time fractions; jump-chain frequencies must be weighted by mean holding times.
  • Expected hitting times solve "holding time plus expected time from the next state" equations.
  • The OU process is the continuous-state, mean-reverting Gaussian Markov process: half-life ln⁡2/θ\ln 2/\theta, stationary variance σ2/(2θ)\sigma^2/(2\theta), and an AR(1) when sampled discretely.

Practice problems

Finished reading?

Answer the 4 knowledge checks to complete this lesson (0 done).