Sautrela

edu.gtts.sautrela.wfsa.models
Class CHMM

java.lang.Object
  extended by edu.gtts.sautrela.wfsa.models.CHMM
All Implemented Interfaces:
NdWFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>, WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>, java.lang.Cloneable

public class CHMM
extends java.lang.Object
implements NdWFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>, java.lang.Cloneable

Continuous Hidden Markov Model

Author:
mpenagar

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.gtts.sautrela.wfsa.WFSA
WFSA.Factory
 
Field Summary
static WFSA.Factory myFactory
           
 
Method Summary
 CHMM clone()
           
 void dumpTrainCounts()
          Dumps the trained data to the model.
 Alphabet<edu.gtts.sautrela.wfsa.models.CHMM.Symbol> getAlphabet()
          Returns the alphabet of the Model.
 double getFinProb(edu.gtts.sautrela.wfsa.models.CHMM.State state)
          Returns the probability of being final
 edu.gtts.sautrela.wfsa.models.CHMM.State getIniState()
          Returns the initial State
 java.lang.String getName()
          Returns the name of the Model.
 Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol> getRandomTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from)
          Returns a random transitions from a state
 Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from)
          Returns all possible transitions from a state.
 Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from, edu.gtts.sautrela.wfsa.models.CHMM.Symbol symbol)
          Returns all possible transitions for the given source state and symbol.
 void incrementTrainCount(edu.gtts.sautrela.wfsa.models.CHMM.State state, double count)
          Increments the training counts associated to a final state.
 void incrementTrainCount(Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol> t, double count)
          Increments the training counts associated to a Transition.
 void initTrainCounts(double initCount)
          Initializes the training counts.
static void main(java.lang.String[] args)
          CHMM - resize/create a continuous Hidden Markov Model.
 void resize(int gNum, int gDim)
          Resize the Gaussians number and dimension.
 void setName(java.lang.String name)
          Sets the name of the HMM.
 void setTrainMean(boolean flag)
          Sets gaussians means training flag.
 void setTrainTrans(boolean flag)
          Sets transitions training flag.
 void setTrainVar(boolean flag)
          Sets gaussians variances training flag.
 void setTrainWeigth(boolean flag)
          Sets gaussians weigths training flag.
 java.lang.String toString()
          Returns a string representation of the object.
 java.lang.String toXML()
          Returns a XML representation of the HMM
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myFactory

public static final WFSA.Factory myFactory
Method Detail

setName

public void setName(java.lang.String name)
Sets the name of the HMM.

Parameters:
name - the name of this HMM

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object

getName

public java.lang.String getName()
Description copied from interface: WFSA
Returns the name of the Model.

Specified by:
getName in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Returns:
The name of the Model

getAlphabet

public Alphabet<edu.gtts.sautrela.wfsa.models.CHMM.Symbol> getAlphabet()
Description copied from interface: WFSA
Returns the alphabet of the Model.

Specified by:
getAlphabet in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Returns:
The Alphabet

getFinProb

public double getFinProb(edu.gtts.sautrela.wfsa.models.CHMM.State state)
Description copied from interface: WFSA
Returns the probability of being final

Specified by:
getFinProb in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Returns:
The probability of being final

getIniState

public edu.gtts.sautrela.wfsa.models.CHMM.State getIniState()
Description copied from interface: WFSA
Returns the initial State

Specified by:
getIniState in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Returns:
The initial state

getTrans

public Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from)
                                                                                                          throws java.lang.UnsupportedOperationException
Description copied from interface: WFSA
Returns all possible transitions from a state.

Specified by:
getTrans in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
from - The source State
Returns:
an array containing all possible transitions from a state. If there is no transition, and empty array must be returned.
Throws:
java.lang.UnsupportedOperationException

getRandomTrans

public Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol> getRandomTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from)
Description copied from interface: WFSA
Returns a random transitions from a state

Specified by:
getRandomTrans in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
from - The source State
Returns:
a random transition

getTrans

public Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.CHMM.State from,
                                                                                                                 edu.gtts.sautrela.wfsa.models.CHMM.Symbol symbol)
Description copied from interface: NdWFSA
Returns all possible transitions for the given source state and symbol. The array should be ordered in descending probability (the most probable transition is the first and the less probable is the last).

Specified by:
getTrans in interface NdWFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
from - the source State
symbol - the observed symbol
Returns:
an array containing all possible transitions. If there is no transition, an empty array must be returned.

setTrainTrans

public void setTrainTrans(boolean flag)
Sets transitions training flag.

Parameters:
flag - if set to true, HMM transitions are trained if false, they are not.

setTrainWeigth

public void setTrainWeigth(boolean flag)
Sets gaussians weigths training flag.

Parameters:
flag - if set to true, HMM gaussians weigths are trained if false, they are not.

setTrainMean

public void setTrainMean(boolean flag)
Sets gaussians means training flag.

Parameters:
flag - if set to true, HMM gaussians means are trained if false, they are not.

setTrainVar

public void setTrainVar(boolean flag)
Sets gaussians variances training flag.

Parameters:
flag - if set to true, HMM gaussians variances are trained if false, they are not.

initTrainCounts

public void initTrainCounts(double initCount)
Description copied from interface: WFSA
Initializes the training counts. Al previous counts are cleared and initCount is used as initial posterior probability count of the WFSA (MAP training). This count must be distributed among all the internal parameters according to their prior probabilities.

Specified by:
initTrainCounts in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
initCount - initial posterior probability count

incrementTrainCount

public void incrementTrainCount(edu.gtts.sautrela.wfsa.models.CHMM.State state,
                                double count)
Description copied from interface: WFSA
Increments the training counts associated to a final state. These counts are related to the final probability of a State.

Specified by:
incrementTrainCount in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
state - the final Sate
count - the training count.

incrementTrainCount

public void incrementTrainCount(Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol> t,
                                double count)
Description copied from interface: WFSA
Increments the training counts associated to a Transition. These counts are related to the probability of a Transition.

Specified by:
incrementTrainCount in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>
Parameters:
t - the Transition
count - the training count.

dumpTrainCounts

public void dumpTrainCounts()
Description copied from interface: WFSA
Dumps the trained data to the model.

Specified by:
dumpTrainCounts in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>

toXML

public java.lang.String toXML()
Returns a XML representation of the HMM

Specified by:
toXML in interface WFSA<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol,Transition<edu.gtts.sautrela.wfsa.models.CHMM.State,edu.gtts.sautrela.wfsa.models.CHMM.Symbol>>

clone

public CHMM clone()
Overrides:
clone in class java.lang.Object

resize

public void resize(int gNum,
                   int gDim)
Resize the Gaussians number and dimension.

Parameters:
gNum - new number of gaussians per state, or 0 for no resize
gDim - new dimension of gaussians, or 0 for no resize

main

public static void main(java.lang.String[] args)
                 throws javax.xml.parsers.ParserConfigurationException,
                        org.xml.sax.SAXException,
                        java.io.IOException
CHMM - resize/create a continuous Hidden Markov Model.
      Syntax:  CHMM [-mMtTvVwW] [-n name] [-N gNum] [-D gDim] URL
 
        -m  Turn off means training.
        -M  Turn on means training.
        -t  Turn off transitions training.
        -T  Turn on transitions training.
        -v  Turn off variances training.
        -V  Turn on variances training.
        -w  Turn off weigths training.
        -W  Turn on weigths training.
        -n name  New name for the CHMM
        -N gNum  Number of Gaussians
        -D gDim  Dimension of Gaussians
        URL  Locator of an existing CHMM
 

Parameters:
args - Command line arguments.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

Sautrela