org.encog.ml.hmm.alog
Class ForwardBackwardCalculator

java.lang.Object
  extended by org.encog.ml.hmm.alog.ForwardBackwardCalculator
Direct Known Subclasses:
ForwardBackwardScaledCalculator

public class ForwardBackwardCalculator
extends Object

The forward-backward algorithm is an inference algorithm for hidden Markov models which computes the posterior marginals of all hidden state variables given a sequence of observations.


Nested Class Summary
static class ForwardBackwardCalculator.Computation
           
 
Field Summary
protected  double[][] alpha
          Alpha matrix.
protected  double[][] beta
          Beta matrix.
protected  double probability
          Probability.
 
Constructor Summary
protected ForwardBackwardCalculator()
          Construct an empty object.
  ForwardBackwardCalculator(MLDataSet oseq, HiddenMarkovModel hmm)
          Construct the forward/backward calculator.
  ForwardBackwardCalculator(MLDataSet oseq, HiddenMarkovModel hmm, EnumSet<ForwardBackwardCalculator.Computation> flags)
          Construct the object.
 
Method Summary
 double alphaElement(int t, int i)
          Alpha element.
 double betaElement(int t, int i)
          Beta element, best element.
protected  void computeAlpha(HiddenMarkovModel hmm, MLDataSet oseq)
          Compute alpha.
protected  void computeAlphaInit(HiddenMarkovModel hmm, MLDataPair o, int i)
          Compute the alpha init.
protected  void computeAlphaStep(HiddenMarkovModel hmm, MLDataPair o, int t, int j)
          Compute the alpha step.
protected  void computeBeta(HiddenMarkovModel hmm, MLDataSet oseq)
          Compute the beta step.
protected  void computeBetaStep(HiddenMarkovModel hmm, MLDataPair o, int t, int i)
          Compute the beta step.
 double probability()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

protected double[][] alpha
Alpha matrix.


beta

protected double[][] beta
Beta matrix.


probability

protected double probability
Probability.

Constructor Detail

ForwardBackwardCalculator

protected ForwardBackwardCalculator()
Construct an empty object.


ForwardBackwardCalculator

public ForwardBackwardCalculator(MLDataSet oseq,
                                 HiddenMarkovModel hmm)
Construct the forward/backward calculator.

Parameters:
oseq - The sequence to use.
hmm - THe hidden markov model to use.

ForwardBackwardCalculator

public ForwardBackwardCalculator(MLDataSet oseq,
                                 HiddenMarkovModel hmm,
                                 EnumSet<ForwardBackwardCalculator.Computation> flags)
Construct the object.

Parameters:
oseq - The sequence.
hmm - The hidden markov model to use.
flags - Flags, alpha or beta.
Method Detail

alphaElement

public double alphaElement(int t,
                           int i)
Alpha element.

Parameters:
t - The row.
i - The column.
Returns:
The element.

betaElement

public double betaElement(int t,
                          int i)
Beta element, best element.

Parameters:
t - From.
i - To.
Returns:
The element.

computeAlpha

protected void computeAlpha(HiddenMarkovModel hmm,
                            MLDataSet oseq)
Compute alpha.

Parameters:
hmm - The hidden markov model.
oseq - The sequence.

computeAlphaInit

protected void computeAlphaInit(HiddenMarkovModel hmm,
                                MLDataPair o,
                                int i)
Compute the alpha init.

Parameters:
hmm - THe hidden markov model.
o - The element.
i - The state.

computeAlphaStep

protected void computeAlphaStep(HiddenMarkovModel hmm,
                                MLDataPair o,
                                int t,
                                int j)
Compute the alpha step.

Parameters:
hmm - The hidden markov model.
o - The sequence element.
t - The alpha step.
j - Thr column.

computeBeta

protected void computeBeta(HiddenMarkovModel hmm,
                           MLDataSet oseq)
Compute the beta step.

Parameters:
hmm - The hidden markov model.
oseq - The sequence.

computeBetaStep

protected void computeBetaStep(HiddenMarkovModel hmm,
                               MLDataPair o,
                               int t,
                               int i)
Compute the beta step.

Parameters:
hmm - The hidden markov model.
o - THe data par to compute.
t - THe matrix row.
i - THe matrix column.

probability

public double probability()
Returns:
The probability.


Copyright © 2014. All Rights Reserved.