public class BaumWelch extends DiscreteHMM
Constructor and Description |
---|
BaumWelch(int[] observations,
DiscreteHMM model0,
int nIteraions)
Constructs an HMM model by training an initial model using the Baum–Welch
algorithm.
|
Modifier and Type | Method and Description |
---|---|
static Vector[] |
gamma(HiddenMarkovModel model,
int[] observations,
Matrix[] xi)
Gets the (T-1 * N) γ matrix, where the (t, i)-th
entry is γt(i).
|
static DiscreteHMM |
train(int[] observations,
DiscreteHMM model0)
Constructs a trained (discrete) hidden Markov model, one iteration.
|
static Matrix[] |
xi(HiddenMarkovModel model,
int[] observations,
ForwardBackwardProcedure fb)
Gets the ξ matrices, where for 1 ≤ t ≤ T - 1, the
t-th entry of ξ is an (N * N) matrix, for which
the (i, j)-th entry is ξt(i, j).
|
B, density, nSymbols
logProbability, logProbability, logProbability
next, nextDouble, seed
public BaumWelch(int[] observations, DiscreteHMM model0, int nIteraions)
observations
- an integer array of observation symbols (length =
T). Each symbol is a positive integer less than or equal to
M (the number of observation symbols per state).model0
- an initial modelnIteraions
- the number of iterationspublic static DiscreteHMM train(int[] observations, DiscreteHMM model0)
model0
- the initial hidden Markov modelobservations
- an integer array of observation symbols (length =
T). Each symbol is a positive integer less than or equal to
M (the number of observation symbols per state).public static Matrix[] xi(HiddenMarkovModel model, int[] observations, ForwardBackwardProcedure fb)
ξt(i, j) = P(qt = si, qt+1 = sj, Ω | λ)This implementation works for both unscaled and scaled alpha-beta probabilities in terms of transition probability estimation. The actual value for the unscaled fwd-bwd probabilities computed using scaled alpha-beta differ by a factor of L(x) the likelihood of observations. But this term appears in both the numerator and denominator so they cancel out. See eq. 18 in hmm-scaling-implementation.
model
- an HMM modelobservations
- an array of observations (length = T).fb
- the alpha-betapublic static Vector[] gamma(HiddenMarkovModel model, int[] observations, Matrix[] xi)
γt(i) = P(qt = si, Ω | λ)
model
- an HMM modelobservations
- an array of observations (length = T).xi
- the ξ matrices; the 0-th entry is not used
to match the time indexCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.