EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ > Class Template Reference

A continuous-time Markov chain on a discrete space: the rate of moving from each value to each other value. More...

#include <EmrysFilter/Distributions/ContinuousTimeMarkovChain.h>

Public Types

using Scalar = Scalar_
 the scalar type of the rates
using SpaceType = Space_
 the discrete space
using MatrixType = typename MarkovChain<Space_, Scalar_>::MatrixType
 The generator's type, the same as a MarkovChain's transition matrix.

Public Member Functions

 ContinuousTimeMarkovChain (Space_ space={})
 The chain that never moves: every rate zero.
template<MatrixExpression Generator>
 ContinuousTimeMarkovChain (Space_ space, Generator &&generator)
 The chain on space with generator generator: nonnegative off the diagonal, with each row summing to zero.
template<MatrixExpression Generator>
requires FixedSizeSpace<Space_>
 ContinuousTimeMarkovChain (Generator &&generator)
 The chain on a FixedSizeSpace, named as the template argument, with generator generator: ContinuousTimeMarkovChain<Maneuver>{rates} (decisions.md [space-storage]).
template<DiscreteSpace... Axes>
requires ( FixedSizeSpace<Space_> && internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v
<internal::DiscreteProductAxes<Space_>> )
 ContinuousTimeMarkovChain (ContinuousTimeMarkovChain< Axes, Scalar_ > const &... chains)
 The chain on a DiscreteProduct that is a FixedSizeSpace, named as the template argument, whose axes move independently by chains.
template<DiscreteSpace... Axes>
requires ( internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v<internal::DiscreteProductAxes<Space_>> )
 ContinuousTimeMarkovChain (Space_ space, ContinuousTimeMarkovChain< Axes, Scalar_ > const &... chains)
 The chain on the DiscreteProduct space whose axes move independently, each by its own chain in chains, one per axis in order.
Space_ const & space () const
MatrixType const & generator () const
Scalar rate (Eigen::Index from, Eigen::Index to) const
MarkovChain< Space_, Scalar_ > transition (TimeStep< Scalar_ > auto const &time) const

Static Public Member Functions

static ContinuousTimeMarkovChain persistent (Scalar rate, Space_ space={})
template<typename DwellTimes, typename ExitWeights>
static ContinuousTimeMarkovChain fromDwellTimes (Eigen::MatrixBase< DwellTimes > const &dwellTimes, Eigen::MatrixBase< ExitWeights > const &exitWeights, Space_ space={})
template<typename DwellTimes>
static ContinuousTimeMarkovChain fromDwellTimes (Eigen::MatrixBase< DwellTimes > const &dwellTimes, Space_ space={})

Static Public Attributes

static constexpr int CardinalityAtCompileTime = Space_::Cardinality
 the number of values, or Eigen::Dynamic
static constexpr int MaxCardinalityAtCompileTime = Space_::MaxCardinality
 a bound on it, or Eigen::Dynamic

Detailed Description

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
class Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >

A continuous-time Markov chain on a discrete space: the rate of moving from each value to each other value.

A time-homogeneous continuous-time Markov chain on a finite set. The generator \( Q \) has a row per value moved from and a column per value moved to: \( Q_{ij} \ge 0 \) for \( i \ne j \) is the rate of jumping from \( i \) to \( j \), and each row sums to zero, so \( -Q_{ii} \) is the rate of leaving \( i \). Its transition over an interval \( \Delta t \) is the MarkovChain with \( \Pi = e^{Q \Delta t} \), which transition() computes with Eigen's matrix exponential, by the scaling and squaring method of Higham (2005), and predict() moves a CategoricalParams over the interval exactly, as each process model discretizes its own noise [continuous-time-noise].

A chain on a DiscreteProduct can be built from independent chains on its axes. Its generator is their Kronecker sum, the rate of one axis jumping while the others stay, since two independent axes never jump at the same instant:

auto const mode = ContinuousTimeMarkovChain<Mode>{maneuver, sensor};
p = predict(p, mode, 0.5); // p e^{Q/2}
ContinuousTimeMarkovChain(Space_ space={})
The chain that never moves: every rate zero.
Definition ContinuousTimeMarkovChain.h:73
static ContinuousTimeMarkovChain persistent(Scalar rate, Space_ space={})
Definition ContinuousTimeMarkovChain.h:171
CategoricalParams< Space, Scalar > predict(CategoricalParams< Space, Scalar > const &prior, MarkovChain< Space, Scalar > const &chain)
Definition Categorical.h:1049
Template Parameters
Space_the discrete space (see Discrete spaces)
Scalar_scalar type of the rates, double by default
See also
MarkovChain, ArrivalInterval, HiddenMarkovFilter

Constructor & Destructor Documentation

◆ ContinuousTimeMarkovChain()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
template<DiscreteSpace... Axes>
requires ( internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v<internal::DiscreteProductAxes<Space_>> )
Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::ContinuousTimeMarkovChain ( Space_ space,
ContinuousTimeMarkovChain< Axes, Scalar_ > const &... chains )
inline

The chain on the DiscreteProduct space whose axes move independently, each by its own chain in chains, one per axis in order.

Its generator is their Kronecker sum.

Member Function Documentation

◆ fromDwellTimes() [1/2]

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
template<typename DwellTimes, typename ExitWeights>
ContinuousTimeMarkovChain Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::fromDwellTimes ( Eigen::MatrixBase< DwellTimes > const & dwellTimes,
Eigen::MatrixBase< ExitWeights > const & exitWeights,
Space_ space = {} )
inlinestaticnodiscard
Returns
the chain on space that stays at value \( i \) for a mean time of \( \tau_i \), dwellTimes, and on leaving jumps to each other value \( j \) in proportion to \( w_{ij} \), exitWeights: \( Q_{ii} = -1/\tau_i \) and \( Q_{ij} = w_{ij} / (\tau_i \sum_k w_{ik}) \).

The time at a value is exponential with mean \( -1/Q_{ii} \), and the jump that ends it goes to \( j \) with probability \( Q_{ij} / -Q_{ii} \), the holding times and jump chain of a continuous-time chain, so these are exactly the chain's mean dwell times and jump probabilities. The dwell times are in the unit of the time steps given to transition(), seconds for a std::chrono::duration (see Time steps), and positive; an infinite one never leaves. The exit weights are nonnegative, need not sum to one, and are zero on the diagonal; a value that is left needs one that isn't zero.

◆ fromDwellTimes() [2/2]

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
template<typename DwellTimes>
ContinuousTimeMarkovChain Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::fromDwellTimes ( Eigen::MatrixBase< DwellTimes > const & dwellTimes,
Space_ space = {} )
inlinestaticnodiscard
Returns
the chain on space that stays at value \( i \) for a mean time of \( \tau_i \), dwellTimes, and on leaving jumps to any other value with equal probability: the other fromDwellTimes() with every exit weight one

◆ generator()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
MatrixType const & Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::generator ( ) const
inlinenodiscard
Returns
the generator \( Q \), with \( Q_{ij} \) the rate of jumping from \( i \) to \( j \)

◆ persistent()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
ContinuousTimeMarkovChain Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::persistent ( Scalar rate,
Space_ space = {} )
inlinestaticnodiscard
Returns
the chain on space that leaves its value at the rate rate and jumps to any other value with equal probability

◆ rate()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
Scalar Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::rate ( Eigen::Index from,
Eigen::Index to ) const
inlinenodiscard
Returns
the rate of jumping from the value from to the value to, or minus the rate of leaving from if they are the same

◆ space()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
Space_ const & Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::space ( ) const
inlinenodiscard
Returns
the discrete space

◆ transition()

template<DiscreteSpace Space_, RealScalar Scalar_ = double>
MarkovChain< Space_, Scalar_ > Emrys::ContinuousTimeMarkovChain< Space_, Scalar_ >::transition ( TimeStep< Scalar_ > auto const & time) const
inlinenodiscard
Returns
the chain over an interval of time, any TimeStep (see Time steps): \( \Pi = e^{Q \Delta t} \)

The documentation for this class was generated from the following file: