How this calculation works
Compute the mean and variance of reward accumulated while a continuous-time Markov chain occupies its states. Rewards are rates per unit time, integrated along the random path up to a fixed horizon. The calculation separates accumulated reward moments from terminal state probabilities and supports a specified initial distribution. It uses finite-state moment equations through an augmented matrix exponential.
R_T=∫₀ᵀr(X_t)dt; m′=Qm+r, s′=Qs+2diag(r)m, m(0)=s(0)=0. E[R_T]=p₀m(T); Var(R_T)=p₀s(T)−[p₀m(T)]².A worked example
For Q=[[-1,1],[2,-2]], reward rates[0,1], initial distribution[1,0] and T=2, mean accumulated reward is .55583097 and variance .21048850. Terminal probability of the rewarded state is .33250708. Multiplying that terminal probability by two would give .66501417, a different quantity from the true expected occupation time.
Good to know
1–3 states; finite row-generator Q with nonnegative off-diagonal rates and row sums zero within10⁻⁹. One finite reward rate per state and a nonnegative initial distribution summing to1 within10⁻⁹. Horizon0<T≤20; augmented matrix-time infinity norm≤80. State reward rates only; no transition bonuses, discounting, policy optimization or reward-distribution recovery. Floating-point moments, with unresolved negative variance rejected.
Reference: Method reference (opens in a new tab) ↗
Reward is earned through time in a state
A reward rate describes how quickly a quantity accumulates while the chain remains in a state. Setting one state’s rate to one and all others to zero makes the accumulated reward its occupation time.
A transition bonus is different: it is earned at the instant a jump occurs rather than throughout a holding interval. This page has no transition-reward input, so entering a jump bonus as a state rate changes both the expected amount and its variance.
Compare this with the Continuous time Markov chain calculator from a rate matrix. Transition probabilities alone do not calculate additive path reward variance.
Use a rate generator rather than a transition matrix
Off-diagonal Q entries are nonnegative jump rates with units inverse time. Each diagonal entry is the negative sum of its row’s outgoing rates, making row sums zero.
A discrete-time matrix whose rows sum to one cannot be used as a generator. The initial probability vector is treated as a row distribution, and the terminal distribution is p₀exp(QT). All rate, horizon and reward units must use a consistent time scale.
The first two moments require different equations
The expected reward by starting state solves m′=Qm+r. Its second moment solves s′=Qs+2diag(r)m, where the extra term carries the interaction between reward already earned and reward added over the next short interval.
Squaring the expected reward does not yield the second moment. The variance uses the difference between the averaged second moment and the square of the averaged first moment, including uncertainty about the initial state when the initial distribution is mixed.
The default occupation-time calculation
The default chain starts in the zero-reward state, jumps toward the rewarded state at rate one and returns at rate two. Reward therefore counts time spent in the second state before time two.
Its expected occupation time is about .555831 and variance .210489. The terminal probability .332507 describes only the state at the endpoint. Replacing the whole occupancy history by that final probability multiplied by the horizon gives a different and incorrect accumulated mean.
An augmented exponential computes coupled moments
The moment equations form a triangular linear system. Placing Q on diagonal blocks and reward-rate couplings above them allows one matrix exponential to recover first and second moments for every possible starting state.
This finite-state construction avoids simulating many random paths merely to estimate two moments. It is still floating-point matrix arithmetic, and its norm bound limits cases where scaling or cancellation can become difficult. No Monte Carlo confidence interval is involved.
Simple invariants check the convention
If every state has the same rate r, accumulated reward is exactly rT on every path and its variance is zero. If every reward rate is multiplied by c, the mean multiplies by c and variance by c².
Adding the same constant rate to every state shifts accumulated reward by a deterministic constant times T, leaving variance unchanged. These checks distinguish integrated state rewards from counts of state visits or terminal reward values.
What two moments leave unresolved
Different reward distributions can share the same mean and variance. These outputs do not determine a percentile, a probability of exceeding a budget or the full distribution of occupation time.
Negative reward rates are mathematically allowed and can represent costs with a signed convention. The calculation does not optimize a policy or infer the rates from data; it propagates the entered chain and reward assumptions over a finite horizon.
A few questions, answered
Are rewards earned on jumps?
No. They are rates integrated while occupying states; transition bonuses are outside this page.
Can a reward be negative?
Yes. Finite signed state reward rates are allowed.
Does terminal probability times horizon give expected reward?
Generally no. Accumulation depends on occupancy throughout the interval.
Can I obtain a reward percentile?
No. Mean and variance do not determine the full reward distribution.