MarkovModel

public struct MarkovModel<T> where T : Hashable

This entity applies MarkovModel for fully observable models, using Markov Chain and Markov decision process. More about Markov Models.

Given N possibles states, this entity calculates predictions of the next states given a current state. It relies on calculations and operations between vector and matrix.

  • The Markov Chain is a matrix which is the essense of Markov Model. It represents the from-to states.

       From
    | 1 0 0 |
    | 0 1 0 | To
    | 0 0 1 |
    

    The data is represented by a bi-dimensional dictionary of integer numbers in order to optimize memory and performance.

    Declaration

    Swift

    public private(set) var chain: Matrix<T>
  • Initialize a Markov Chain with an array of transitions, indicating the history of state transitions that the chain will be built upon.

    Complexity

    O(n), where n is the length of the transitions.

    Declaration

    Swift

    public init(transitions: [T])

    Parameters

    transitions

    An array describing the sequence of consecutive transitions.

  • This method is dedicated for large transition data processing.

    Complexity

    O(n), where n is the length of the transitions.

    Declaration

    Swift

    public static func process(transitions: [T], completion: (Matrix<T>) -> Void)

    Parameters

    transitions

    An array describing the sequence of consecutive transitions.

    completion

    The closure in wich the matrix can be freely manipulated.

  • A pretty printed representation of the Markov Chain (matrix)

            From
    | 1.00  0.00  0.00 |
    |                  |
    | 0.00  1.00  0.00 | To
    |                  |
    | 0.00  0.00  1.00 |
    

    Declaration

    Swift

    public var description: String { get }