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

A7 · Lesson 35 · Markov chains and reliability

Steady states, settling times and the expected time to failure

A wireless link drifts between a good state, where errors are rare, and a bad one, where a fade wipes out whole bursts of bits. A redundant power supply has two units; either can carry the load, a failed one gets repaired, and the system only goes down if the second fails before the first is back. Neither has a simple formula, but both are Markov chains: a vector of probabilities that a fixed matrix multiplies forward one step at a time. Lesson 34 showed that such a matrix has the eigenvalue 1. This lesson uses the whole spectrum: the eigenvector for 1 is the long-run behavior, the next eigenvalue says how fast it arrives, and an inverse matrix gives the expected time until something breaks.

  • The solid curve is the mean time to failure of two units with repair, against the probability per hour that a failed unit is repaired. The dashed lines are the same two units with no repair, and one unit alone.
  • Slide the failure probability. Halving it roughly quadruples the repaired system's life, but only doubles the others'.

Predict

A link in its good state stays good with probability 0.95 each step; in its bad state it recovers with probability 0.3 each step. In the long run, what fraction of steps is it bad?

Name it

The transition matrix

Number the states and let column j of P hold the probabilities of moving from state j to each state, so every column adds to 1. If 𝐱k holds the probabilities of being in each state at step k,

𝐱k+1=P𝐱k𝐱k=Pk𝐱0

The steady state

Because every column adds to 1, the row vector of ones satisfies 𝟏TP=𝟏T, so 1 is an eigenvalue of P. Its eigenvector, scaled so its entries add to 1, is the steady state 𝝅: P𝝅=𝝅. For two states with switching probabilities p (from 1 to 2) and q (back),

𝝅=(qp+q,pp+q)

How fast it settles

Write 𝐱0 in the eigenvectors of P. Each step multiplies each component by its eigenvalue, so everything except the steady state shrinks like |λ2|k, where λ2 is the next-largest eigenvalue in size. For two states λ2=1−p−q. A chain whose |λ2| is close to 1 has a long memory.

Absorbing chains and the time to failure

A state you can't leave, like "both supplies down", is absorbing. Put the transient states first; the part of P that moves among them is a square block Q. Then

N=(I−Q)−1=I+Q+Q2+⋯

is the fundamental matrix: Nij is the expected number of steps spent in transient state i starting from state j. Adding up column j gives the expected number of steps before absorption, the mean time to failure from state j.

Worked example

A link has P=[0.950.30.050.7] (state 1 good, state 2 bad). The bit error rate is 0.001 in the good state and 0.1 in the bad one. Find the steady state, the average error rate, and how many steps it takes a link that starts good to come within 1% of the steady state.

Show the solution
  1. Eigenvalues. They are 1 and 1−0.05−0.3=0.65
  2. Steady state. (0.3,0.05)/0.35=(0.857,0.143)
  3. Average error rate. 0.857×0.001+0.143×0.1=0.0151 nearly all of it from the 14% of the time in fades.
  4. Approach to steady state. Starting good, the bad-state probability approaches 0.143 with an error that shrinks by 0.65 each step.
  5. Within 1%. That needs 0.65k<0.01: k>ln⁡0.01ln⁡0.65=10.7 so 11 steps.

Answer the steady state is (0.857,0.143), the average error rate is 0.0151, and a link that starts good is within 1% of the steady state after 11 steps.

Worked example

Two supplies each fail with probability 0.001 per hour. A failed one is repaired with probability 0.1 per hour, but if the second fails first, the system is down. Starting with both working, what is the expected time to system failure? What would it be without repair?

Show the solution
  1. States. The transient states are "both up" and "one up"; "both down" absorbs.
  2. Transitions. Per hour, both-up moves to one-up with probability 0.002 (either unit failing). One-up returns with probability 0.1 and fails with 0.001. So Q=[0.9980.10.0020.899]
  3. Fundamental matrix. N=(I−Q)−1=[505005000010001000]
  4. Mean time to failure. From both-up the system spends 50 500 hours, on average, with both working and 1000 with one, so its mean time to failure is 51 500 hours.
  5. Without repair. With 0.1→0, N's first column becomes (500,1000): 1500 hours, only 1.5 times a single unit's 1000.
  6. Compare. Repair multiplies the redundant system's life by 34, which is why redundancy without maintenance buys so little.

Answer 51 500 hours with repair, and 1500 hours without it.

Worked example

A machine is "running", "degraded" or "failed and being repaired". Each hour, running stays running with 0.98 and degrades with 0.02; degraded fails with 0.1, stays with 0.85 and is serviced back to running with 0.05; failed is repaired to running with 0.25 and stays failed otherwise. What fraction of the time is it running?

Show the solution
  1. Find the steady state. Each column of P adds to 1, and the eigenvector for λ=1, scaled to add to 1, is the steady state:
import numpy as np
P = np.array([[0.98, 0.05, 0.25],
              [0.02, 0.85, 0.00],
              [0.00, 0.10, 0.75]])
w, V = np.linalg.eig(P)
pi = np.real(V[:, np.argmin(abs(w - 1))])
pi /= pi.sum()
print(pi)          # [0.8427 0.1124 0.0449]
  1. Read the result. Running 84.3% of the time, degraded 11.2% and down 4.5%.
  2. How fast it settles. The other two eigenvalues, a complex pair 0.79±0.02j, say a disturbance dies away by a factor of 0.79 an hour: to under 1% within 20 hours.
  3. Check by hand. The balance checks it: degraded is entered at 0.02πr and left at 0.15πd, so πd=0.133πr

Answer it's running 84.3% of the time (degraded 11.2% and down 4.5%).

Check

A two-state channel goes from good to bad with probability 0.05 per step and from bad to good with 0.2. In the long run, what fraction of the steps is it bad?

Check

The same kind of channel, with p = 0.05 and q = 0.15.

(a)

What is the second eigenvalue of its transition matrix?

(b)

How many steps does a bad spell last on average?

Check

A unit fails with probability 0.001 per hour and is never repaired.

(a)

What is one unit's mean time to failure, in hours?

(b)

Two such units run in parallel, and the system fails when both have. What is its mean time to failure?

Check

The starter gives a 3-state transition matrix P (columns add to 1). Set pi to its steady state from np.linalg.eig (the eigenvector for the eigenvalue nearest 1, scaled to add to 1), lam2 to the size of the next-largest eigenvalue, and x50 to the state probabilities after 50 steps from state 0, found by repeated multiplication.

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

Check

Two supplies each fail with probability lam = 0.001 per hour; a failed one is repaired with probability mu = 0.02 per hour, and the system is down if both fail. Build Q for the transient states (both up, one up) as in the second example, set N to the fundamental matrix, mttf to the expected hours to system failure from both up, and gain to mttf divided by the value with no repair.

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

Check

Simulate the two-state channel (p = 0.05 good to bad, q = 0.3 back) for 200 000 steps with rng = np.random.default_rng(s), starting good, drawing one uniform number per step: leave the current state if the number is below that state's switching probability. Set frac_bad to the fraction of steps spent bad and mean_burst to the average length of the bad spells, then compare with p/(p+q) and 1/q.

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

Check

Why does every transition matrix (columns adding to 1) have 1 as an eigenvalue?

Check

Derive the two-state steady state. The chain moves from state 1 to 2 with probability p and back with q.

Step 1

In the steady state the flow from 1 to 2, pπ1, equals the flow back, qπ2. What is π2/π1?

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°.

Explain why

A redundant system's mean time to failure jumped from 1500 to 51 500 hours when repair was added. Explain where the extra time comes from, in terms of the chain.

Practice

Keep practicing

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