Advanced maths

Markov generator reconstruction calculator using a principal matrix logarithm

Test whether the principal matrix logarithm of an observed transition matrix is a valid continuous-time Markov generator.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Test whether the principal matrix logarithm of an observed transition matrix is a valid continuous-time Markov generator.

THE FORMULAQ=Log(P)/delta; Q1=0; q_ij>=0 for i!=j; exp(delta Q)=P.

A worked example

For [[0.8,0.2],[0.2,0.8]] observed over one time unit, the principal generator has off-diagonal rate -log(0.6)/2, approximately 0.255412812, and opposite diagonal entries.

Good to know

Real row-stochastic matrix order2–4 and positive observation interval, principal logarithm resolved real and off the branch cut. Check row sums, off-diagonal rates and exponential reconstruction. A valid Q certifies one embedding; an invalid principal Q does not prove nonembeddability in general and must be labeled unresolved beyond that branch.

From observed transitions to continuous time

A row-stochastic matrix records transition probabilities across a fixed observation interval. A continuous-time Markov generator instead contains nonnegative transition rates off the diagonal and row sums equal to zero. Exponentiating that generator times the observation interval must recover the observed transition matrix. Finding such a generator is an embedding question, not simply taking a logarithm of each entry.

The principal matrix logarithm gives one specified candidate when its branch is defined. This page checks that candidate against the generator constraints and reconstructs the original matrix by exponentiation. A valid candidate certifies one continuous-time embedding. An invalid principal candidate does not generally prove that no other real logarithm branch could supply a valid generator.

Markov generator reconstruction calculator using a principal matrix logarithm worked example01r ≈ 0.25541Observed interval = 1Stay probability = 0.8Switch probability = 0.2
Scroll across to see the full diagram.
For [[0.8,0.2],[0.2,0.8]] observed over one time unit, the principal generator has off-diagonal rate -log(0.6)/2, approximately 0.255412812, and opposite diagonal entries.

Compare this with the Continuous time Markov chain calculator from a rate matrix. Infer a candidate continuous-time rate generator from an observed transition matrix, rather than evolve a supplied generator forward in time.

Preparing a stochastic input

Enter a small square real matrix with nonnegative entries and rows summing to one, along with a strictly positive observation interval. Row-stochastic means that distributions advance using the convention stated on the page; transposing a column-stochastic matrix is a deliberate modeling conversion. A matrix with negative entries is not repaired automatically by clipping them to zero.

Rounded probabilities may produce small row-sum residuals. The permitted tolerance should be explicit, and any normalization policy should be stated rather than silently changing the data. Singular transition matrices do not have a finite matrix logarithm. Eigenvalues on the principal logarithm's branch cut also require rejection or a clearly unresolved status under this particular candidate construction.

The principal logarithm is a matrix function

Matrix logarithms depend on the spectrum and invariant structure of the whole matrix. Entrywise logarithms usually produce the wrong shape, negative off-diagonal numbers and unrelated row sums. The matrix candidate Q is the principal logarithm divided by the observation interval, so its units are inverse time and its magnitude scales inversely with that interval.

Computing a real candidate can require scaling, square roots or resolvent-based numerical methods. The implementation must check branch and convergence conditions rather than accept any real-looking array returned by an iteration. A small internal series term is not enough if the series was applied outside its convergence region or if an unresolved eigenvalue lies near a prohibited branch.

Checking generator constraints

Every off-diagonal entry of Q must be nonnegative within the declared numerical tolerance, and each row must sum to zero. The diagonal is then the negative total exit rate from that state. Its sign is not independent evidence of validity: a matrix can have negative diagonals while still containing an impermissible negative transition rate elsewhere.

Exponentiate the candidate over the observation interval and compare with the original transition matrix. This reconstruction residual checks the logarithm computation separately from the rate inequalities. Passing the rate constraints with a poor reconstruction does not establish an embedding, just as accurate reconstruction with negative off-diagonal rates does not make the candidate a Markov generator.

A symmetric two-state example

The default transition matrix has diagonal probabilities 0.8 and off-diagonal probabilities 0.2, observed over one time unit. Its eigenvalues are one and 0.6. A symmetric two-state generator has equal off-diagonal rates r and diagonal entries minus r, giving a nonconstant transition eigenvalue exp(-2r). Equating that value to 0.6 determines the rate.

The result is r equal to minus one half log 0.6, approximately 0.255412812. Thus the generator is [[-r,r],[r,-r]]. Its exponential has stay probability (one plus exp(-2r)) divided by two, which is 0.8, and switch probability 0.2. This independent formula checks the logarithm, interval scaling and row convention without another matrix-log routine.

Interpreting a failed principal candidate

If a resolved principal logarithm reconstructs the input but has a materially negative off-diagonal entry, the principal branch is not a valid generator. The correct status is limited to that candidate. Other logarithms can differ by spectral branch choices, so a general no-embedding conclusion requires additional analysis beyond the tests implemented on this page.

Likewise, a numerical branch failure is not a theorem of nonembeddability. Keep the three outcomes distinct: a checked valid principal generator, a checked invalid principal generator, and an unresolved principal computation. This distinction prevents a useful sufficient certificate from being misrepresented as an exhaustive decision procedure for every stochastic matrix in the supported size range.

Using the rates and interval responsibly

If the same transition matrix is interpreted over twice the observation duration, the candidate rates are halved. The probabilities themselves do not change. This is why the time interval must be recorded with the matrix: omitting it makes the numerical rates uninterpretable. A stochastic observation alone also does not prove that the physical process is time-homogeneous or truly continuous-time Markov.

The page does not estimate the matrix from counts, attach confidence intervals to rates or select between competing stochastic models. Input uncertainty can matter strongly near branch or positivity boundaries. A successful algebraic embedding check answers consistency for the entered ideal matrix; it does not certify the assumptions or statistical quality of the observations that produced it.

A few questions, answered

Can I take the logarithm of each probability?

No. A matrix logarithm is a function of the whole linear operator, not an entrywise operation.

Does a valid principal generator prove embeddability?

Yes, when its rate constraints and exponential reconstruction pass the stated checks.

Does an invalid principal generator prove nonembeddability?

Not in general. Another matrix-logarithm branch may behave differently, so the conclusion is limited to the principal candidate.

What units do the rates have?

They are inverse units of the supplied observation interval.

Find your calculator

Start typing to explore the library.