Skip to contents

This function retrieves a transition matrix from a BirdFlow object, possibly calculating it from a marginal.

Usage

get_transition(x, transition)

Arguments

x

A BirdFlow object

transition

A transition code, e.g. "T_01-02"

Value

A transition matrix

Details

get_transition() will construct a transition matrix from the marginals if x doesn't have transitions, or return the relevant stored transition matrix if it does.

The format for a transition code is "T_[from]-[to]" where [from] and [to] are timesteps padded with zeros. Direction is important; "T_03-04" represents a transition backward in time.

The transition matrices are structured such that you multiply the matrix by the distribution to project either forward or backwards. If more than one distribution is projected at once they should be stored in columns of a matrix with dimensions(n_active(), n_distr()).

Given a marginal in which the cell [i, j] represents the probability of the bird being in state i in the prior timestep and state j in the next, to generate the forward transition matrix we divide each row of the marginal by its sum and then transpose. Backwards transitions matrices are generated by dividing each column by its sum, without transposing.

See also

lookup_transitions() will generate a list of the transitions needed to predict or route between two points in time that can then be passed to this function. The internal function transition_from_marginal() does the calculations.