liveBook · Manning

Equilibrium

As explained in Statistics Every Programmer Needs

Equilibrium is a condition in which a system's relevant quantities remain effectively unchanged because opposing changes balance out.

Equilibrium is a stable distribution of probabilities across a Markov chain’s states. Individual systems may still change state, but transitions balance so the overall probabilities remain effectively unchanged. This steady-state distribution helps forecast long-run behavior rather than just the next period. section 11.3 section 11.5

Let π be a row vector of state probabilities and P the transition probability matrix. Each period, calculate π_next = π @ P. At equilibrium, π @ P = π: another transition leaves the distribution unchanged. Repeated multiplication provides a direct way to see whether the probabilities are approaching that condition. section 11.3.1 section 11.5

Forecast an engine’s operating state

For states running and not running, start with the engine running and apply the same transition matrix for 30 periods: import numpy as np pi = np.array([1.0, 0.0]) P = np.array([[0.90, 0.10], [0.20, 0.80]]) for _ in range(30): pi = pi @ P print(np.round(pi, 4)) # [0.6667 0.3333] The result describes long-run probabilities, not a guarantee that a particular engine will stay running. Around period 10, the running probability is still about 0.676; later transitions bring it closer to two-thirds. section 11.3.1 section 11.3

>>> pi_0 = np.array([1, 0])    #1

>>> P = np.array([
>>>     [0.90, 0.10],
>>>     [0.20, 0.80]
>>> ])     #2

>>> n_periods = 20     #3

>>> state_probabilities = [pi_0]     #4

>>> for _ in range(n_periods):
>>>     pi_next = np.dot(state_probabilities[-1], P)
>>>     state_probabilities.append(pi_next)     #5

>>> for i, pi in enumerate(state_probabilities):
>>>     print(f'Period {i} = {pi}')    #6
Period 0 = [1 0]
Period 1 = [0.9 0.1]
Period 2 = [0.83 0.17]
Period 3 = [0.781 0.219]
Period 4 = [0.7467 0.2533]
Period 5 = [0.72269 0.27731]
Period 6 = [0.705883 0.294117]
Period 7 = [0.6941181 0.3058819]
Period 8 = [0.68588267 0.31411733]
Period 9 = [0.68011787 0.31988213]
Period 10 = [0.67608251 0.32391749]
Period 11 = [0.67325776 0.32674224]
Period 12 = [0.67128043 0.32871957]
Period 13 = [0.6698963 0.3301037]
Period 14 = [0.66892741 0.33107259]
Period 15 = [0.66824919 0.33175081]
Period 16 = [0.66777443 0.33222557]
Period 17 = [0.6674421 0.3325579]
Period 18 = [0.66720947 0.33279053]
Period 19 = [0.66704663 0.33295337]
Period 20 = [0.66693264 0.33306736]

Inspect the period-by-period state vectors to see the changes shrink rather than treating a single forecast as equilibrium. section 11.3.1

Check the model before interpreting a stable result:

  • The next state must depend on the current state rather than the full history; transition probabilities and the system’s size and makeup are assumed constant over time. section 11.1
  • A chain with absorbing states needs a different long-run interpretation: accounts may ultimately settle in terminal states, and their breakdown matters for risk decisions. section 11.4

How Statistics Every Programmer Needs covers it

How deep it goes
Defines a stable probability vector and works through iterative matrix computation; does not establish general conditions guaranteeing convergence.
Examples
Tracks a running-versus-not-running engine toward roughly two-thirds running probability and notes diminishing changes in forecast market shares.
What it assumes
Assumes basic probability and Python familiarity while explaining state vectors, transition matrices, and the Markov property.
What you can do after
Apply it via NumPy matrix multiplication to forecast state distributions and interpret their apparent stabilization.
How it connects
Connects equilibrium to Markov chains, state probability vectors, transition probability matrices, and absorbing states.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.