A1150 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A11 · Lesson 50 · Markov chains

Randomness with a short memory: burst errors and queues

Lesson 4 found that a wireless link losing 1% of packets can lose the next one 40% of the time after a loss. Independent losses can't do that, but a model with two hidden states can: a "good" state where almost nothing is lost and a "bad" state, during a fade, where half the packets vanish. The link hops between them at random, and where it goes next depends only on where it is now. That's a Markov chain, the simplest model of randomness with memory. It describes burst errors, buffers filling and draining, and the state machines inside protocols.

  • A two-state channel starts in the good state. Each packet time it moves from good to bad with probability a and from bad back to good with probability b.
  • The curve is the chance of being in the bad state after n packets. It climbs to a steady value and stays there.
  • Make b small: the bad state lasts longer, so losses come in longer bursts. What sets the steady value, and what sets how fast it's reached?

Predict

A channel goes from good to bad with probability 0.01 per packet and from bad to good with probability 0.2. What fraction of the time is it in the bad state, in the long run?

Name it

Markov chains

A process moving among states 1,2,…,m at steps n=0,1,2,… is a Markov chain if the next state depends only on the current one:

P(Xn+1=j∣Xn=i,Xn−1,…)=P(Xn+1=j∣Xn=i)=Pij

The transition matrix P collects these probabilities; each row adds to 1. The time spent in a state before leaving is geometric (lesson 10), with mean 11−Pii.

Evolving the distribution

Write the chance of each state at step n as a row vector πn. Then

πn+1=πnPπn=π0Pn

The entry (Pn)ij is the chance of going from i to j in exactly n steps, the sum over every path of the product of its steps (lesson 4's multiplication rule).

Steady state

For a chain that can reach every state from every other and doesn't cycle rigidly, πn settles to a unique stationary distribution π with

πP=π∑iπi=1

π is a left eigenvector of P with eigenvalue 1 (A7.33). The long-run fraction of time spent in each state is πi. For two states with P(G→B)=a and P(B→G)=b:

πB=aa+bπn(B)=πB(1−(1−a−b)n) starting from G

The other eigenvalue, 1−a−b, sets how fast the start is forgotten.

The Gilbert–Elliott channel

Give each state its own loss probability, ℓG small and ℓB large. The long-run loss rate is πGℓG+πBℓB, but the losses cluster in the bad spells, which is what makes them bursty. That's why interleaving (spreading a code word's bits far apart in time) helps so much on fading links: it turns one burst into scattered single errors a code can fix.

Worked example

A Gilbert–Elliott channel has a=0.01, b=0.2, and loses packets with probability 0.001 in the good state and 0.5 in the bad. Find the long-run loss rate and the mean burst length.

Show the solution
  1. Steady state. πB=0.010.21=0.0476 and πG=0.952.
  2. Loss rate. P=0.952×0.001+0.0476×0.5=0.00095+0.0238=0.0248
  3. Burst length. Bad spells last 10.2=5 packets on average, during which about half the packets are lost.

Answer the long-run loss rate is 0.0248, and bad spells last 5 packets on average.

Worked example

Starting in the good state, what is the chance the same channel is bad two packets later?

Show the solution
  1. Path G→B→B. This is one of the two paths that end in B: 0.01×0.8=0.008
  2. Path G→G→B. 0.99×0.01=0.0099
  3. Add the paths. 0.008+0.0099=0.0179
  4. Check with the formula. πB(1−0.792)=0.0476×0.376=0.0179

Answer the channel is bad two packets later with chance 0.0179.

Worked example

A two-state channel goes from good to bad with probability 0.01 per packet and recovers with probability 0.2. What fraction of the time is it bad, and how long do bad spells last?

Show the solution
  1. Balance the flows. In the steady state, πgood×0.01=πbad×0.2
  2. Fraction of time bad. πbad=0.010.21=0.048 about 5%.
  3. Length of a bad spell. Each bad spell lasts a geometric number of packets with mean 10.2=5
  4. What it means. Errors come in bursts of about five packets, which is why codes for such channels interleave their data.

Answer the channel is bad about 5% of the time, in spells of 5 packets on average.

Check

A two-state channel moves good→bad with probability 0.01 and bad→good with probability 0.1 per step. What fraction of the time is it bad, in the long run?

Check

A channel leaves its bad state with probability 0.25 per packet. How many packets does a bad spell last on average?

Check

With good→bad probability 0.02 and bad→good 0.2, starting in the good state, what is the chance of being bad two steps later?

Check

A Gilbert–Elliott channel has a = 0.01, b = 0.2, and loses packets with probability 0.002 when good and 0.5 when bad. What is the long-run loss rate?

Check

Starting in the good state, with a = 0.05 and b = 0.15, what is the chance of being in the bad state after 10 steps?

Check

Which of these makes a process a Markov chain?

Check

A channel goes bad with probability 0.01 per packet and recovers with probability 0.2.

(a)

What fraction of the time is it bad?

(b)

How long does a bad spell last, in packets, on average?

Check

Starting good, the chance of being bad after n steps is πb(1−(1−a−b)n) with πb=aa+b.

Step 1

Evaluate it.

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

Simulate the two-state channel (bad with probability 0.01 per step from good, good with 0.2 from bad) for 10⁶ steps (np.random.default_rng(7)), starting good. Set frac_bad and mean_spell, the average length of bad spells.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does a two-state channel produce bursty losses even though its long-run loss rate can be small?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.