be.ac.ulg.montefiore.run.jahmm
Class ForwardBackwardCalculator

java.lang.Object
  extended by be.ac.ulg.montefiore.run.jahmm.ForwardBackwardCalculator
Direct Known Subclasses:
ForwardBackwardScaledCalculator

public class ForwardBackwardCalculator
extends java.lang.Object

This class can be used to compute the probability of a given observations sequence for a given HMM. Once the probability has been computed, the object holds various information such as the alpha (and possibly beta) array, as described in Rabiner and Juang.

Computing the beta array requires a O(1) access time to the observation sequence to get a theoretically optimal performance.


Nested Class Summary
static class ForwardBackwardCalculator.Computation
          Flags used to explain how the observation sequence probability should be computed (either forward, using the alpha array, or backward, using the beta array).
 
Field Summary
protected  double[][] alpha
           
protected  double[][] beta
           
protected  double probability
           
 
Constructor Summary
protected ForwardBackwardCalculator()
           
  ForwardBackwardCalculator(java.util.List<? extends O> oseq, Hmm<O> hmm)
          Computes the probability of occurence of an observation sequence given a Hidden Markov Model.
  ForwardBackwardCalculator(java.util.List<? extends O> oseq, Hmm<O> hmm, java.util.EnumSet<ForwardBackwardCalculator.Computation> flags)
          Computes the probability of occurence of an observation sequence given a Hidden Markov Model.
 
Method Summary
 double alphaElement(int t, int i)
          Returns an element of the alpha array.
 double betaElement(int t, int i)
          Returns an element of the beta array.
protected
<O extends Observation>
void
computeAlpha(Hmm<? super O> hmm, java.util.List<O> oseq)
           
protected
<O extends Observation>
void
computeAlphaInit(Hmm<? super O> hmm, O o, int i)
           
protected
<O extends Observation>
void
computeAlphaStep(Hmm<? super O> hmm, O o, int t, int j)
           
protected
<O extends Observation>
void
computeBeta(Hmm<? super O> hmm, java.util.List<O> oseq)
           
protected
<O extends Observation>
void
computeBetaStep(Hmm<? super O> hmm, O o, int t, int i)
           
 double probability()
          Return the probability of the sequence that generated this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

protected double[][] alpha

beta

protected double[][] beta

probability

protected double probability
Constructor Detail

ForwardBackwardCalculator

protected ForwardBackwardCalculator()

ForwardBackwardCalculator

public ForwardBackwardCalculator(java.util.List<? extends O> oseq,
                                 Hmm<O> hmm,
                                 java.util.EnumSet<ForwardBackwardCalculator.Computation> flags)
Computes the probability of occurence of an observation sequence given a Hidden Markov Model.

Parameters:
hmm - A Hidden Markov Model;
oseq - An observation sequence.
flags - How the computation should be done. See the Computation enum.

ForwardBackwardCalculator

public ForwardBackwardCalculator(java.util.List<? extends O> oseq,
                                 Hmm<O> hmm)
Computes the probability of occurence of an observation sequence given a Hidden Markov Model. This computation computes the alpha array as a side effect.

See Also:
ForwardBackwardCalculator(List, Hmm, EnumSet)
Method Detail

computeAlpha

protected <O extends Observation> void computeAlpha(Hmm<? super O> hmm,
                                                    java.util.List<O> oseq)

computeAlphaInit

protected <O extends Observation> void computeAlphaInit(Hmm<? super O> hmm,
                                                        O o,
                                                        int i)

computeAlphaStep

protected <O extends Observation> void computeAlphaStep(Hmm<? super O> hmm,
                                                        O o,
                                                        int t,
                                                        int j)

computeBeta

protected <O extends Observation> void computeBeta(Hmm<? super O> hmm,
                                                   java.util.List<O> oseq)

computeBetaStep

protected <O extends Observation> void computeBetaStep(Hmm<? super O> hmm,
                                                       O o,
                                                       int t,
                                                       int i)

alphaElement

public double alphaElement(int t,
                           int i)
Returns an element of the alpha array.

Parameters:
t - The temporal argument of the array (positive but strictly smaller than the length of the sequence that helped generating the array).
i - A state index of the HMM that helped generating the array.
Returns:
The alpha array (t, i) element.
Throws:
{@link - UnsupportedOperationException UnsupportedOperationException} if alpha array has not been computed.

betaElement

public double betaElement(int t,
                          int i)
Returns an element of the beta array.

Parameters:
t - The temporal argument of the array (positive but smaller than the length of the sequence that helped generating the array).
i - A state index of the HMM that helped generating the array.
Returns:
The beta beta (t, i) element.
Throws:
{@link - UnsupportedOperationException UnsupportedOperationException} if beta array has not been computed.

probability

public double probability()
Return the probability of the sequence that generated this object. For long sequences, this probability might be very small, or even meaningless because of underflows.

Returns:
The probability of the sequence of interest.


Copyright © 2004,2005 Jean-Marc François.