Continuous-Time Markov Chains
Thirteen modules on continuous-time Markov chains and on what happens when their rates come in two very different sizes: fast mixing inside groups of states, slow movement between them. Run the chains, change the rates and the small parameter ε, watch the equations solve themselves, then check yourself with concept questions and practice problems.
Follows the chapter order of G. G. Yin and Q. Zhang, Continuous-Time Markov Chains and Applications: A Two-Time-Scale Approach, 2nd ed. (Springer, Stochastic Modelling and Applied Probability 37, 2013), covering all ten chapters. Chapter numbers refer to that book; the questions, examples and models here are written for this page.
Generators and sample paths
A continuous-time Markov chain on finitely many states is determined by one matrix, its generator . The diagonal says how long the chain waits in each state, and the off-diagonal entries say where it goes next. Set the rates below and run the chain.
The idea
The transition matrix then satisfies and
Why two time scales. In the systems the book has in mind (machines that fail and get repaired, queues, networks, economic regimes) some rates are much larger than others. Writing the generator as , with a small , separates the fast moves from the slow ones. Modules 4 to 13 are about that limit. Note that generates the same chain as , only run times faster.
Explore
Worked example
Take the generator
Describe how the chain moves, find its stationary distribution, and compare the fraction of time in each state with the fraction of jumps into it.
What are the mean holding times in states 1, 2, 3?
The leaving rates are , so the mean holding times are .
Write down the transition matrix of the jump chain.
Divide each off-diagonal entry by its row's leaving rate and put zeros on the diagonal:
From state 2 the chain always returns to 1.
Solve , .
The third column gives , so . The first column gives , so . The second column, , checks out. Normalising,
The jump chain has its own stationary distribution (with ). How is it related to ?
The chain enters state at long-run rate (time fraction times leaving rate), so :
Check: . State 1 gets the most jumps but state 2 holds the most time, because the chain lingers there.
Check your understanding
Row of a generator is , with in the middle. What is the chance the next jump goes to the third state, and how long does the chain wait on average?
- Probability ; mean wait .
- Probability ; mean wait .The holding time is exponential with rate 4. Its mean is the reciprocal of the rate.
- Probability in a short time ; there is no single "next jump" probability. is the chance of a jump to state 3 within time . Conditioned on a jump happening, the destination has a fixed distribution.
Why must every row of a generator sum to zero?
- Because the stationary distribution satisfies . is a statement about the columns, weighted by . It is a property of one special vector, not of the rows.
- Because each row of sums to 1 for all ; differentiate at .
- Because probabilities are nonnegative.Nonnegativity is why the off-diagonal entries are . It says nothing about the sum.
Chain A has generator and chain B has generator . Which is true?
- B has a different stationary distribution, ten times larger.: the same solves both systems, and it must still sum to 1.
- B has a different jump chain.The jump probabilities are ratios ; multiplying every rate by 10 cancels.
- Same jump chain and same , but B runs ten times faster: has the law of .
Practice
The two-state chainAn explicit transition matrix
A two-state chain jumps at rate and at rate . Find explicitly and its limit as .
Hint
solves . Alternatively, has eigenvalues and .
Solution
The equation with gives
Both rows tend to , at the exponential rate .
From the martingale to the forward equationTaking expectations
Let . Using the martingale characterisation with , show that .
Solution
For we get (using ). A martingale has constant expectation, so
Differentiating gives , the forward equation of the next module.
The forward equation and irreducibility
The distribution of a Markov chain solves a linear differential equation, . For three states every solution is a curve in a triangle, and you can drag its starting point. When the generator is weakly irreducible, every curve ends at the same point.
The idea
Explore
Worked example
A two-state chain has time-varying rates: at rate and at rate . Compare the quasi-stationary distribution with the actual distribution .
Find . When is weakly irreducible, and when irreducible?
reads , so . This needs (weak irreducibility); both entries are positive when both rates are positive (irreducibility).
Write the forward equation for alone.
Using :
Solve it when the rates are constant.
The gap to closes at rate , the absolute value of the nonzero eigenvalue of .
Now let the rates vary. What equation does the gap satisfy, and what does it say?
Since , the equation becomes , so
The chain is pulled toward at rate while moves away at speed . If the rates are and , then does not depend on , the pull wins, and settles near , which is . That small lag is exactly what Module 4 computes.
Check your understanding
. Is weakly irreducible?
- Yes: state 1 is transient, so its stationary probability is 0 and . is a solution, but is it the only one? Look at state 3.
- No: solves for every .
- Yes, because has rank .Two rows of are zero and the first is nonzero, so the rank is 1, not 2.
In the "Cyclic" example the path of spirals into . What causes the spiral?
- The chain is periodic.A continuous-time chain is never periodic: for every .
- has a pair of complex eigenvalues , so contains terms and .
- Rounding error in the numerical solution.The spiral is real. Try smaller and smaller steps and it stays.
is weakly irreducible for every and varies slowly. Is for all if ?
- Yes, because is stationary. would be stationary for a chain whose rates stayed frozen at time . Here they keep moving.
- No: lags behind , unless happens to be constant.
Practice
The solvability conditionOne direction of the Fredholm alternative
Let be a generator. Show that if has a solution then . If is weakly irreducible, show the solution is unique once is fixed.
Solution
. If with , then has and , so by the second form of weak irreducibility.
Why is a stochastic matrixPositivity without probability
Show directly from the matrix exponential that has nonnegative entries and rows summing to 1 when is a generator.
Hint
Choose . Then has nonnegative entries, and and commute.
Solution
, a sum of nonnegative matrices. And since . This also gives a way to simulate: run a Poisson clock of rate and move by at each tick (uniformisation).
Birth–death chains and a finite queue
Most Markov models are built by listing what can happen next and at what rate. In a birth–death chain the state only moves up or down by one, and that is enough to solve for the stationary distribution in closed form. Here it is for a queue with a waiting room of size .
The idea
The book's catalogue of models goes on: system reliability (components failing and being repaired), competing risks, Cox processes, random evolutions, seasonal models, and chains inside optimisation algorithms and controlled systems. The common thread is time-scale separation: in each, some rates are naturally much larger than others, and makes that explicit.
Explore
Worked example
Two identical machines each fail at rate while running. One repairer fixes failed machines one at a time at rate . Let be the number of failed machines. Find the long-run availability (at least one machine working) for .
Write the generator.
With 0 failed, two machines can fail: rate . With 1 failed, one can fail (rate ) or the repair finishes (rate ). With 2 failed, only repair (rate ):
Use detailed balance to express in terms of .
and .
Normalise with , and give the availability.
, and the entries sum to , so . Availability .
Suppose repairs are much faster than failures: . How does the downtime scale?
. A machine is under repair a fraction of the time, and the second one must fail during that short repair, which has probability . Fast repairs make the chain spend almost all its time in state 0: a first glimpse of a two-time-scale model.
Check your understanding
In the finite queue, take . What is the stationary distribution?
- There is none: the queue is critically loaded.That is true for an infinite waiting room. With room for only customers the chain is finite and irreducible.
- Uniform: .
- Concentrated at .Detailed balance with gives : no state is preferred.
Why does the fraction of arrivals that are turned away equal , the fraction of time the system is full?
- Because the server is idle exactly of the time.True, but that is about state 0. What is special about the moments when customers arrive?
- Arrivals come from a Poisson process independent of the past of the queue, so the state an arrival sees has the time-stationary distribution.
- It doesn't: arrivals are more likely when the queue is short.Here the arrival rate is in every state, so arrivals do not prefer any state.
A birth–death chain on has every and positive. Is it reversible (does detailed balance hold)?
- Always.
- Only when for all .That is the special case of a uniform . Detailed balance only needs , which can always be arranged.
- Only for the finite queue.The cut argument uses nothing about the particular rates.
Practice
A tiny queue by handLittle's law
Take , , . Find , the mean number in the system , the throughput, and the mean time a customer who gets in spends in the system.
Solution
, so , giving . . Accepted customers arrive at rate , which is also the throughput. Little's law: .
Zero flow across a cutDeriving detailed balance
For a birth–death chain with stationary , add up the equations for and conclude .
Solution
. For , the inner sum is minus the rate of leaving from , which is for and 0 otherwise. For it is the rate of entering , which is for and 0 otherwise. So the sum is .
A fast chain: outer expansion and initial layer
Speed a chain up by a factor while its rates drift in ordinary time. Its distribution snaps to the quasi-stationary distribution within a time of order , then follows it. A matched asymptotic expansion describes both phases, with an error you can watch shrink in proportion to .
The idea
Let be generated by , with weakly irreducible and smooth on . Its distribution solves
Outer terms. Substitute and match powers of :
with and for . So , the quasi-stationary distribution, and each later equation is solvable by the Fredholm alternative because .
Initial layer. In the stretched time, and , so
which decays like because .
Explore
Two states. Rates for and for , with and , so .
Worked example
For the two-state chain of the explorer, with rates and , find , and the first outer correction , and evaluate them at .
What is ?
The quasi-stationary distribution: . With , .
Find .
A zero-sum row vector times is , so
In the explorer and .
Solve with .
Write . Then and , so
When rises, sits slightly below it: the chain lags behind its moving target by about , as in Module 2.
Evaluate at , where and .
and , so . For : . The explorer's last two boxes compare this with the exact value.
Check your understanding
Why can't the outer expansion alone match the initial condition ?
- is forced by ; it is not free to equal .
- It can, if enough terms are kept.Every with carries a factor . No combination of them can close an gap .
- Because the outer terms are not smooth at .They are as smooth as . The trouble is their value at 0, not their smoothness.
is a 3-state generator with nonzero eigenvalues and . For small , how does the initial layer decay?
- Like .The layer lives on the fast time .
- Like .The fast mode dies first. What is left after that?
- Like (for a typical ).
Suppose . Which is true?
- exactly for all .Only if is constant. Otherwise the chain lags behind its moving target.
- , but is still of order .
- The error becomes .The term is still there; only the zeroth-order layer disappeared.
Practice
Constant generatorsWhen the expansion terminates
If does not depend on , show that exactly. Which terms of the expansion are nonzero?
Solution
, and since . So , , and all other terms vanish: with forces , and so on.
Uniform away from zeroReading the error bound
Use the bound to show that for each fixed , while does not tend to 0 unless .
Solution
on , and . At the difference is for every .
Weak and strong interactions
Now the fast part of the generator splits the states into groups that do not communicate, and a slow part moves the chain between groups. Inside each group the distribution equilibrates almost at once. The weights of the groups follow a smaller Markov chain whose generator is an average of the slow rates.
The idea
So , and given the group, the chain is spread according to . The group weights have no zeroth-order layer: only moves probability inside groups, so .
Explore
Fast rates: 2, 1, 1, 3 (all divided by ε). Slow rates: 0.9, 0.3, 0.4, 1.2.
Worked example
Compute everything the explorer uses: , , and when the chain starts in . Then find the long-run distribution of the full chain to leading order.
Find and .
For a two-state block with rates (first to second) and (back), . So and .
Compute and .
and . So
Solve for with .
By the two-state formula from Module 1, and .
What is the stationary distribution of the full chain, to leading order in ?
Let in the leading term: , so
A direct computation with gives , against here. The 4-state problem has been reduced to three 2-state problems: one for each group, and one for the aggregated chain.
Check your understanding
Group 1 has . From the slow rate into group 2 is 2; from it is 0. What is ?
- 2That is the rate from only. The chain spends half of its group-1 time in , where it cannot leave.
- 1
- 0, the smaller rateThe aggregated rate is an average, not a minimum.
In the right-hand plot the group probabilities show no fast transient at the start, even when the chain starts in a single state. Why?
- is block diagonal, so the fast dynamics only move probability inside a group; each group's total changes at rate .
- Because sums to 1.That is true but says nothing about time evolution. What does do to the total mass of a group?
- They do have one, it is just too small to see.At leading order it is exactly zero: .
What happens if ?
- converges to a unique stationary distribution.With the groups never communicate, so the chain is not irreducible.
- stays at its initial value: the group weights are frozen, and inside each group the distribution tends to .
- The theorem fails.It still applies, with .
Practice
is a generatorTwo lines
Show that has nonnegative off-diagonal entries and zero row sums.
Solution
For , , a nonnegative combination of off-diagonal entries of . Row sums: .
Where comes fromAveraging the forward equation
Multiply the forward equation on the right by . Assuming , derive .
Solution
Since , the term drops out: . The left side is the vector of group weights, approximately . On the right, , so the right side is .
Transient and absorbing states
Add states that the fast dynamics leaves and never returns to. Their probability dies out within a time of order , and the mass they held is handed to the recurrent groups in proportions that one linear solve gives. Absorbing states are the simplest recurrent groups of all.
The idea
Read as a routing rule. A slow jump straight into another group counts as it is. A slow jump into a transient state is followed, within time , by a fast exit into group with probability given by ; only the part that lands in a different group is a real change of group.
Explore
Recurrent group (fast rates 1 and 2 between them), absorbing state , transient states . Fast: 2, 1, 1, 0.5, 1. Slow: 0.3, 0.4, 0.5.
Worked example
For the chain in the explorer, compute the exit probabilities and the aggregated generator .
Write and check that it is Hurwitz.
On : . Its row sums are and , so each diagonal entry outweighs the rest of its row and, by Gershgorin's theorem, every eigenvalue has negative real part. (They are and .)
Find by a first-step argument.
From : with probability go straight to , with to . From : to , to , to . So and , giving , . This is written out; and .
Starting in , what is ?
. The explorer's right panel shows the mass settling to these levels within a few multiples of .
Compute and .
. From : is a direct change of group, weight ; changes group only if the chain then exits to , weight . So . From : , then on to with probability : .
Check your understanding
A transient state has fast rate 3 into group 1 and fast rate 1 into group 2, and no other moves. The chain starts at . What is ?
- The two exits are not equally likely: they race at rates 3 and 1.
- These are rates; is a probability vector.
Transient states have probability after the initial layer. Why not simply delete them and use as the aggregated generator?
- That would be fine: states with vanishing probability cannot matter.Small probability is not the same as small flow. Slow jumps into transient states happen at rate .
- Slow jumps into transient states happen at rate , and a fraction of them end in a different group; dropping them loses real group changes.
- Because would no longer be invertible.Deleting the states removes altogether. The problem is what happens to .
For , the total probability of the transient states is:
- exactly 0.The slow part keeps feeding the transient states.
- of order : fed at rate by slow jumps, drained at rate .
- decaying like .The drain is fast, on the scale , but the feed never stops.
Practice
Two absorbing statesA slow leak back
States 1 and 2 are absorbing for the fast part; state 3 is transient with fast rates 1 into state 1 and 2 into state 2. Slowly, state 1 jumps to 3 at rate and state 2 jumps to 3 at rate . Find and the long-run fraction of time in state 1 as .
Solution
. From state 1, a slow jump leads to state 2 with probability : . Similarly . The stationary weight of state 1 is .
The exit probabilities add upUsing the row sums
Show that .
Solution
The transient rows of say . Multiply by : . Starting from a transient state, the fast chain leaves with probability 1.
Occupation measures and their fluctuations
The forward equation tells us . Applications usually need something about one path: how much time it actually spent in state . That time, minus its expected share, goes to zero like , and divided by it becomes Gaussian.
The idea
For a constant this is , with the deviation matrix .
Why . In time the fast chain goes through about nearly independent cycles, each contributing a centered amount of size to . A sum of such terms has standard deviation .
Explore
Generator with , so . Time runs over .
Worked example
A two-state chain has rates () and (). Find the limiting variance of , and use it to estimate the spread of the time spent in state 1 during when and .
What is for the unscaled generator?
From Module 1, , with .
Compute .
Find .
Check against renewal theory: on and off periods with means , and variances , give variance per unit time , which is the same expression.
Now , . How spread out is the time spent in state 1 during ?
, so , a standard deviation of 0.05. The time in state 1 is or so, even though the chain makes about 100 jumps. Fluctuations of order are much larger than the errors of the forward equation.
Check your understanding
You divide by 4. The typical size of is:
- divided by 4.That is how the mean , of order , scales. The fluctuations are larger.
- divided by 2.
- unchanged.That is true of , not of .
Which statement about and the typical value of is right?
- Both are .The mean is. A random quantity can be much larger than its mean in absolute value.
- The mean is ; the typical size is of order .
- The mean is of order ., and Module 4 bounds the integrand by .
The explorer starts each chain from . If instead every chain started in state 1, would the limit of change?
- Yes: the mean would shift by an amount of order 1.How long does the effect of the starting state last, and how much does it contribute to ?
- No: the starting state matters only for a time of order , which changes by and by .
Practice
The deviation matrixA closed form
Let be irreducible and . Show that , and that this matrix satisfies and .
Hint
and . Compute .
Solution
Since and commute, , using . The eigenvalues of are (on ) and the nonzero eigenvalues of , all with negative real part, so . Hence . Finally and for every .
A tail estimateUsing the Gaussian limit
With and as in the worked example, estimate the probability that the chain spends more than 0.55 time units in state 1 during .
Solution
We need , i.e. . With limiting standard deviation , that is one standard deviation: probability .
The aggregated process
With weak and strong interactions, a single sample path splits into two parts. Which group the chain is in behaves more and more like a Markov chain with generator . Where it is inside the group becomes a fast blur, whose time fractions are given by .
The idea
The centering uses the random indicator , not a deterministic function: the time spent in a group stays random in the limit, because itself is random. Scaled by , these occupation errors converge to a switching diffusion, a Brownian motion whose variance rate depends on the current value of ; its one-time distributions are Gaussian mixtures rather than Gaussian.
Explore
The four-state chain of Module 5: , , , .
Worked example
In the explorer's chain, show that is not a Markov chain for fixed , and explain why it becomes one in the limit.
Through which states can the chain enter ?
The slow moves into are (rate 0.4) and (rate 1.2). So it enters at or at , depending on where it was in .
Just after entering, what is the rate of leaving ?
0.9 if it entered at , 0.3 if at . The future of depends on more than its present value 1, so is not Markov.
How long does the chain remember its entry point?
The block has nonzero eigenvalue . After a time of a few times the position inside has distribution close to , whatever the entry point.
What does a stay in look like in the limit?
Over a stay of order 1, the exit rate is averaged against and equals . The memory lasts only , so stays become exponential with mean 2, independent of the past: the Markov property returns in the limit.
Check your understanding
On a fixed interval , as :
- both the number of jumps and the number of group switches grow like .Group switches are driven by , whose rates do not depend on .
- the number of jumps grows like but the number of group switches stays of order 1.
- both stay of order 1.Inside a group the rates are of order .
Why is time in compared with rather than with ?
- The two give the same limit. does not go to 0: the time spent in is random even in the limit.
- The time the path spends in stays random as , so only the split inside the group becomes deterministic.
- Because is not known explicitly.It is: it solves . The issue is randomness, not computability.
When is exactly a Markov chain for every ?
- Never.It can be, under a condition on .
- When, for each pair of groups , every state of has the same total slow rate into .
- When every is irreducible.The explorer's blocks are irreducible, and still is not Markov there.
Practice
Long-run time in one stateCombining the two scales
For the explorer's chain, find the limit as of the long-run fraction of time spent in .
Solution
The aggregated chain spends a fraction of the time in , and inside a fraction is in . Answer: , the same as in the worked example of Module 5.
Lumpability exactlyChecking the Markov property
Change the explorer's slow rates so that becomes Markov for every while stays the same.
Solution
Give both states of slow rate 0.5 into (say at 0.5 and at 0.5), and both states of rate 0.6 into . The averages with and are still 0.5 and 0.6, and now the exit rate does not depend on the state inside the group.
Backward equations and the terminal layer
An expected payoff collected at a final time solves the backward equation, which runs from back toward 0. The two-time-scale picture holds in reverse: a thin layer just before where values inside a group merge, then a slow evolution governed by the same as before.
The idea
Duality. Forward equations act on row vectors (distributions), and the leading term has the form . Backward equations act on column vectors (functions), and the leading term has the form . In both, governs the slow evolution. Value functions of control problems are backward objects, so Chapters 7 to 10 rest on this expansion.
Explore
Worked example
Use the four-state chain of Module 5 with , so . Find the leading-order answer for well before .
What does the terminal layer do to ?
Inside , the values 1 and 0 merge into their -average ; inside both are 0. So .
Solve backward from , writing .
. With and , the first column of is , so
What do both tend to as ? Interpret.
, the long-run probability of found in Module 5. Far from , the starting state is forgotten.
Is there a terminal layer when is constant on each group, say ?
No: , so . The answer is to leading order. Try the "indicator of " preset: the curves leave without any fast transient.
Check your understanding
Near the values and differ. Going back from , how long until they agree to within 1%?
- A time of order (here about ).
- A time of order 1.The merging is done by the fast part , not the slow part.
- They never agree: their payoffs differ.The payoffs differ only at . Starting slightly earlier, the chain has time to mix inside its group.
Which average of the payoff over a group enters ?
- The plain average over the states of the group.States are not visited equally often by the fast chain.
- The -weighted average .
- The value at the state the chain is in at time .That state is forgotten within a time of order .
Why is the boundary layer at for the backward equation, but at 0 for the forward equation?
- Each equation has a layer where its data are given: at time 0 for the forward equation, at time for the backward one.
- Because changes fastest near .The layer appears even for constant generators. It is about the side condition.
- The backward equation has layers at both ends.Its condition is imposed only at ; at nothing has to be matched.
Practice
A maximum principleBounds on expected payoffs
Show that for all and all , in two ways: probabilistically, and from the matrix form .
Solution
Probabilistically, is an expectation of , which lies between the min and max. In matrix form, each row of is a probability vector, so is a convex combination of the . In the explorer, no curve ever leaves the range of the four dots.
Probability of ending in a groupNo layer at all
For in the explorer's chain, find and the leading-order value of when .
Solution
, and with : , . At , and , so .
Markov decision problems on two time scales
When a controller can change the rates, the optimal cost solves a dynamic-programming equation on the full state space. On two time scales, a smaller problem with one state per group gets the value right to within , and its decisions give a policy that is nearly optimal for the original problem.
The idea
Explore
Each entry reads action 0 / action 1. Group is the cheap regime, the expensive one. Action 1 ("maintain") costs more; it slows the drift into or speeds the return. Discount rate .
Worked example
Solve the explorer's limit problem for the decision , , and compare it with , .
With , what are , and ?
Fast rates: at 2, at 3, so . Then and .
Same for group 2 with .
at 1, at 4, so , and .
Solve .
and . The determinant is , so
Now try with the same . Is it better?
, , . Solving gives : cheaper to run, but the chain drifts into the expensive group more than twice as fast. Checking all 16 decisions shows is optimal, so , and the explorer confirms it is exactly optimal for the full problem once .
Check your understanding
Why is a decision in the limit problem a whole tuple , one action per state of the group, rather than a single action for the group?
- Different states of the group can use different actions, and the mix determines , hence both and .
- Because the limit problem has more states than the original.It has fewer: one per group.
- A single action per group would give the same value.Not here: the optimal uses both actions in each group.
At the optimal policy is , not . Does this contradict the theorem?
- Yes: should be optimal.The theorem promises near-optimality as , not optimality at a given .
- No: the theorem says , which at allows a visible gap.
As , , although the running costs in those states differ. Why?
- Because the optimal actions in the two states are equal.In the limit policy they are not: 0 in , 1 in .
- The chain moves between and within a time of order , so the starting state affects the cost only over a time of order .
- Because discounting makes all values equal.The values of the two groups stay different, about 4.85 and 7.44.
Practice
Discounted costs are averagesThe resolvent
Show that for a generator and . Conclude that it has nonnegative entries with row sums , so is a weighted average of running costs.
Solution
, and . Integrating over (the integrand decays since is stochastic) gives . Entries are nonnegative because is, and row sums are .
The long-run average cost of Letting ρ → 0
In the limit, what is the long-run average cost per unit time of the policy in the explorer?
Solution
The aggregated chain under has , , so it spends fractions and of the time in the two groups. The average cost is .
Production planning with an unreliable machine
A machine breaks down and is repaired at random, and its output must meet a steady demand. A good policy keeps a safety stock, the hedging point. When breakdowns and repairs are fast compared with the time scale of the costs, the right safety stock is of order , and the problem reduces to a deterministic one in which the machine has its average capacity.
The idea
The example. One machine, up or down: breakdown rate , repair rate . Surplus (inventory minus backlog) , with when up and when down; cost per unit time, long-run average. A hedging-point policy with level produces at full rate below , exactly at , and nothing above. This is the classical setting where such policies are known to be optimal.
Average capacity is , and the limit problem is a reliable machine of that capacity. If that exceeds , the limit plan keeps forever at zero cost.
Explore
(up two thirds of the time), capacity , demand , inventory cost , backlog cost .
Worked example
Find the long-run behaviour of the surplus under a hedging-point policy, the optimal , and how it scales with . Assume .
Which levels does visit in the long run, and with which velocities?
Once below , never goes above it. Up and below : . Up at : . Down: . So the stationary law lives on , with an atom at (machine up and waiting).
Let be the stationary densities below . Why is , and what form must they have?
In equilibrium the net flow of probability across any level is zero: mass crosses upward at rate and downward at rate . The balance equation for the up state, , then gives with
So has a law that does not depend on : an atom at 0 and an exponential tail of mean depth of order , proportional to .
Differentiate , where and . What is the optimality condition?
Since the law of is free of , ( has no atom at 0 when ). So at the optimum
a "critical fractile": backlog should occur a fraction of the time with .
With the explorer's numbers, find .
. Normalising the densities and the atom shows for every and , so . Setting this to : , so
Both and the optimal cost are proportional to , and tend to the limit problem's answers, 0 and 0.
Check your understanding
Keep fixed and let . What does the long-run cost tend to?
- 0, the value of the limit problem.Only if shrinks too. With you keep one unit of stock.
- : excursions below are only deep, so nearly all the time.
- .The average capacity exceeds demand, so the surplus is stable for every .
In the limit problem, why does the capacity enter only through ?
- Because the planner should prepare for the worst case, capacity 0.Worst-case planning would ignore that the machine is up most of the time.
- The machine state switches so fast that production averages out: over any interval of order 1 it is up a fraction of the time.
- Because the policy produces at full speed all the time.It cannot produce when the machine is down.
In the explorer, doubling doubles . Why?
- Down periods last , so the dips below are deep, and the safety stock that guards against them scales the same way.
- Because the cost rates are proportional to .The cost rates do not change with .
- It is a coincidence of these parameter values.It holds for any parameters: the whole stationary law of is a rescaling by .
Practice
When is the surplus stable?The sign of β
Show that exactly when the average capacity exceeds demand, . What happens to the surplus otherwise?
Solution
, and . If the inequality fails, the average drift below , , is ; the surplus drifts to (or is null recurrent at equality) and the long-run cost is infinite.
The limit problem from a backlogA deterministic plan
In the limit problem with the explorer's numbers, start from and ignore discounting over the transient. What is the optimal plan, how long does it take to clear the backlog, and what does it cost?
Solution
Produce at the full average rate until : , so it takes 4 time units. Then hold , producing whenever the machine is up. The cost is .
Tuning a threshold by stochastic approximation
When the cost of a threshold policy has no formula, simulate it. A stochastic-approximation recursion uses noisy estimates of the slope of the cost, taken from short simulated runs, and walks the threshold toward the optimum. Here it is on the machine of Module 11, where the exact answer is known, so you can see how well it does.
The idea
Explore
The machine of Module 11 with ; finite-difference step . Each step simulates the next window of length twice, at and at , continuing from where the previous window ended.
Worked example
The finite difference has its own bias: even with perfect cost estimates, the recursion settles where the difference quotient vanishes, not where does. Compute that point for the explorer's machine ().
From Module 11, write for .
, with .
For , compute the exact central difference .
Integrate over and divide by :
Where does it vanish?
At , i.e.
Evaluate the bias for and .
: , bias , invisible next to the noise. : , , bias . A large gives quieter estimates but a biased answer: the usual trade-off of finite differences.
Check your understanding
Why run and on the same machine history?
- Otherwise the gradient estimate would be biased.Independent runs give an estimate with the same mean. The difference is in its variance.
- The noise in the two cost estimates is then largely shared and cancels in the difference, so the slope estimate has much smaller variance.
- To save simulation time.Both runs still have to be simulated; only the machine history is shared.
With a constant step size , what do the iterates do in the long run?
- Converge to exactly.Each step adds noise of size (noise in ), which never stops.
- Fluctuate in a neighbourhood of whose size shrinks as .
- Drift away, because the noise accumulates.Near the mean step pulls them back.
Which ODE describes the iterates for small , ignoring the finite-difference bias?
- , the gradient flow of the long-run cost.
- , with the noisy estimates.In the limit the noise averages out; the ODE involves only its mean.
- .The recursion moves against the slope, not against the cost itself.
Practice
A pathwise derivativeNo finite differences needed
Start the surplus at and keep the machine history fixed. Show that does not depend on , and derive the unbiased slope estimate for .
Solution
The dynamics of involve only and the machine state (full speed when , match demand at ), and . So with free of . Then , and differentiating under the integral gives , which is the formula. This is infinitesimal perturbation analysis; it uses one run instead of two.
A Markov chain approximationDiscretising a drift
For with constant , build a continuous-time chain on the grid with the right mean drift and a variance per unit time that vanishes as .
Solution
Jump at rate and at rate . The mean drift is and the variance per unit time is . With the machine state added, the grid chain jumps also as does, and its DP equation is the upwind discretisation of the HJB equation.
LQ control with Markov switching
A linear system whose coefficients switch with a Markov chain is best controlled by a linear feedback whose gain depends on the current regime. The gains come from coupled Riccati equations, one per state of the chain. On two time scales, they collapse to one averaged Riccati equation per group.
The idea
Only the Riccati part is shared within a group. The feedback still uses the and of the current state.
Explore
Scalar system, the four-state chain of Module 5. , , , , . Averages: , .
Worked example
A scalar system switches very fast between two regimes, and , spending fractions of the time in them; in both, . Find the limiting Riccati solution and its long-horizon gain, and check the closed loop.
Write the scalar Riccati equations for the two regimes.
, .
Why are and nearly equal for small ?
The coupling term is huge unless . Any difference is damped at rate , so .
Average the two equations with weights to get an equation for the common value .
The terms cancel because . What remains is with : , . Its solution is .
Far from the gain is , so . Is the closed loop stable?
In regime 1 the closed loop is , unstable on its own. In regime 2 it is . With fast switching, : stable. The averaged design stabilises the switched system though it would not stabilise regime 1 alone.
Check your understanding
Where does the term in the Riccati equation for regime come from?
- From the Brownian noise .The noise only enters the equation for , through .
- From the chance of switching to regime : it is the generator of acting on the value function .
- From the terminal cost . enters only through the terminal condition.
In the nearly optimal feedback , which part no longer depends on the state inside the group?
- , the Riccati solution; and are still those of the current state.
- All of it: the feedback depends only on the group.The controller still knows the current state and uses its and .
- None of it.The Riccati part is shared within a group, as the explorer shows.
To form the averaged equation, a student averages first and then squares: . What is wrong?
- Nothing; it gives the same answer.In the explorer's group 2, , while .
- The control enters the cost quadratically, so the right average is , which is larger by Jensen's inequality.
- One should average instead of the coefficients. is the unknown being solved for; the coefficients are what get averaged.
Practice
From HJB to RiccatiThe scalar case
For a scalar system with one regime, substitute into and derive the equations for and .
Solution
The minimum over is at , with minimum value . Matching the terms: ; the constant terms: . Terminal conditions , .
The long-horizon gainAn algebraic Riccati equation
For one scalar regime, find the limit of as , and check it against the worked example.
Solution
Set : , whose positive root is . With and , , the limit of . The closed loop rate is : always stable.