A Markov chain on a discrete space: the probability of moving from each value to each value in one step.
More...
|
|
| MarkovChain (Space_ space={}) |
| | The chain that never moves.
|
|
template<MatrixExpression Transitions> |
| | MarkovChain (Space_ space, Transitions &&transitions) |
| | The chain on space with transition matrix transitions: nonnegative, with each row summing to one.
|
template<MatrixExpression Transitions>
requires FixedSizeSpace<Space_> |
| | MarkovChain (Transitions &&transitions) |
| | The chain on a FixedSizeSpace, named as the template argument, with transition matrix transitions: MarkovChain<Maneuver>{matrix} (decisions.md [space-storage]).
|
template<DiscreteSpace... Axes>
requires ( internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v<internal::DiscreteProductAxes<Space_>> ) |
| | MarkovChain (Space_ space, MarkovChain< 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.
|
template<DiscreteSpace... Axes>
requires ( FixedSizeSpace<Space_> && internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v
<internal::DiscreteProductAxes<Space_>> ) |
| | MarkovChain (MarkovChain< Axes, Scalar_ > const &... chains) |
| | The chain on a DiscreteProduct that is a FixedSizeSpace, named as the template argument, whose axes move independently by chains: MarkovChain<Mode>{maneuver, sensor}.
|
| Space_ const & | space () const |
| MatrixType const & | matrix () const |
| Scalar | transition (Eigen::Index from, Eigen::Index to) const |
| CategoricalParams< Space_, Scalar_ > | next (Eigen::Index from) const |
template<DiscreteSpace Space_, RealScalar Scalar_ = double>
class Emrys::MarkovChain< Space_, Scalar_ >
A Markov chain on a discrete space: the probability of moving from each value to each value in one step.
A time-homogeneous Markov chain on a finite set. The transition matrix \( \Pi \), a right stochastic matrix, has a row per value moved from and a column per value moved to, so \( \Pi_{ij} = P(j \mid i) \) and each row sums to one. predict() moves a Categorical one step: \( p'_j = \sum_i p_i \Pi_{ij} \).
A chain on a DiscreteProduct can be built from independent chains on its axes, whose matrix is their Kronecker product, as a maneuver regime and a sensor's outlier state switch independently:
MarkovChain(Space_ space={})
The chain that never moves.
Definition Categorical.h:847
static MarkovChain persistent(Scalar stay, Space_ space={})
Definition Categorical.h:934
A chain is often known by how long it stays at each value and where it goes when it leaves. fromDwellTimes() builds it from both, and stationary() gives the distribution it settles into, the prior for a mode that has run long before the first measurement:
auto const exits = Eigen::Matrix3d{{0, 2, 1}, {1, 0, 0}, {1, 0, 0}};
static MarkovChain fromDwellTimes(Eigen::MatrixBase< DwellTimes > const &dwellTimes, Eigen::MatrixBase< ExitWeights > const &exitWeights, Space_ space={})
Definition Categorical.h:973
std::expected< CategoricalParams< Space, Scalar >, ChainError > stationary(MarkovChain< Space, Scalar > const &chain)
Definition Categorical.h:1069
- Template Parameters
-
| Space_ | the discrete space (see Discrete spaces) |
| Scalar_ | scalar type of the probabilities, double by default |
template<DiscreteSpace Space_, RealScalar Scalar_ = double>
template<DiscreteSpace... Axes>
requires ( internal::IsDiscreteProduct<Space_> && sizeof...(Axes) == std::tuple_size_v<internal::DiscreteProductAxes<Space_>> )
| Emrys::MarkovChain< Space_, Scalar_ >::MarkovChain |
( |
Space_ | space, |
|
|
MarkovChain< 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 matrix is their Kronecker product.
template<DiscreteSpace Space_, RealScalar Scalar_ = double>
template<typename DwellTimes, typename ExitWeights>
| MarkovChain Emrys::MarkovChain< 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 of \( \tau_i \) steps, dwellTimes, and on leaving moves to each other value \( j \) in proportion to \( w_{ij} \), exitWeights: \( \Pi_{ii} = 1 - 1/\tau_i \) and \( \Pi_{ij} = w_{ij} / (\tau_i \sum_k w_{ik}) \).
The number of steps at a value, counting the step that reached it, is geometric with mean \( 1 / (1 - \Pi_{ii}) \), so each \( \tau_i \) is at least one, and 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. A dwell time in seconds with a fixed step is ContinuousTimeMarkovChain::fromDwellTimes() and its transition() over the step, which is exact where \( 1 - \Delta t / \tau_i \) is not.