class Markov::TransitionMatrix(LinkType)


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


Defined in:



Instance Method Summary

Constructor Detail

def : JSON::PullParser) #

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

[View source]
def #

Creates a new empty TransitionMatrix.

[View source]

Instance Method Detail

def add(link : LinkType) #

Adds item to TransitionMatrix

[View source]
def probabilities : Hash(LinkType, Float32) #

Returns decimal probability of each transition in the matrix

[View source]
def probable_transition : LinkType #

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

[View source]
def sum : Int32 #

Returns sum of all values (occurrences) in the matrix

[View source]