class

Markov::TransitionMatrix(LinkType)

Inherits Hash / Iterable / Enumerable / Reference / Object

A TransitionMatrix is an object for storing and selecting transitions in a Markov::Chain.

See https://en.wikipedia.org/wiki/Stochastic_matrix

Constructors

new(pull : JSON::PullParser)

Makes it possible to use #to_json and #from_json (see Crystal docs)

Source
new

Creates a new empty TransitionMatrix.

Source

Instance methods

probabilities

Returns decimal probability of each transition in the matrix

Source
probable_transition

Chooses a random, probable transition from the transitions in the matrix. If matrix is empty, will throw Markov::Exceptions::EmptyTransitionMatrixException

Source
sum

Returns sum of all values (occurrences) in the matrix

Source