hmm

fun hmm(pi: DoubleArray, a: DenseMatrix, b: DenseMatrix): HMM(source)

Creates a first-order Hidden Markov Model from initial, transition, and emission probabilities.

Return

the Hidden Markov Model.

Parameters

pi

the initial state probabilities.

a

the state transition probability matrix, where a[i][j] is P(s_j | s_i).

b

the symbol emission probability matrix, where b[i][j] is P(o_j | s_i).


Creates a first-order Hidden Markov Model from initial, transition, and emission probability arrays.

Return

the Hidden Markov Model.

Parameters

pi

the initial state probabilities.

a

the state transition probability matrix, where a[i][j] is P(s_j | s_i).

b

the symbol emission probability matrix, where b[i][j] is P(o_j | s_i).


fun hmm(observations: Array<IntArray>, labels: Array<IntArray>): HMM(source)

Fits a first-order Hidden Markov Model by maximum likelihood estimation.

Return

the fitted Hidden Markov Model.

Parameters

observations

the observation sequences, of which symbols take values in [0, n), where n is the number of unique symbols.

labels

the state labels of observations, of which states take values in [0, p), where p is the number of hidden states.


fun <T> hmm(observations: Array<Array<T>>, labels: Array<IntArray>, ordinal: (T) -> Int): HMMLabeler<T>(source)

Fits a first-order Hidden Markov Model sequence labeler for generic observation objects.

Return

the HMM sequence labeler.

Parameters

observations

the observation sequences.

labels

the state labels of observations, of which states take values in [0, p), where p is the number of hidden states.

ordinal

a lambda returning the ordinal numbers of symbols in [0, n).

Type Parameters

T

the data type of observations.