org.encog.ml.hmm

## Class HiddenMarkovModel

- java.lang.Object
- - org.encog.ml.BasicML
  - - org.encog.ml.hmm.HiddenMarkovModel

- All Implemented Interfaces:
    Serializable, Cloneable, MLMethod, MLProperties, MLStateSequence

      public class HiddenMarkovModel
      extends BasicML
      implements MLStateSequence, Serializable, Cloneable

  A Hidden Markov Model (HMM) is a Machine Learning Method that allows for predictions to be made about the hidden states and observations of a given system over time. A HMM can be thought of as a simple dynamic Bayesian network. The HMM is dynamic as it deals with changes that unfold over time. The Hidden Markov Model is made up of a number of states and observations. A simple example might be the state of the economy. There are three hidden states, such as bull market, bear market and level. We do not know which state we are currently in. However, there are observations that can be made such as interest rate and the level of the S&P500. The HMM learns what state we are in by seeing how the observations change over time. The HMM is only in one state at a given time. There is a percent probability that the HMM will move from one state to any of the other states. These probabilities are arranged in a grid, and are called the state transition probabilities. Observations can be discrete or continuous. These observations allow the HMM to predict state transitions. The HMM can handle single-value or multivariate observations. http://www.heatonresearch.com/wiki/Hidden_Markov_Model Rabiner, Juang, An introduction to Hidden Markov Models, IEEE ASSP Mag.,pp 4-16, June 1986. Baum, L. E.; Petrie, T. (1966). "Statistical Inference for Probabilistic Functions of Finite State Markov Chains" The Annals of Mathematical Statistics 37 (6): 1554-1563.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `TAG_COVARIANCE`
    `static String` | `TAG_DIST_TYPE`
    `static String` | `TAG_ITEMS`
    `static String` | `TAG_MEAN`
    `static String` | `TAG_PI`
    `static String` | `TAG_PROBABILITIES`
    `static String` | `TAG_STATES`
    `static String` | `TAG_TRANSITION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HiddenMarkovModel(int states)` Construct a discrete HMM with the specified number of states.
    `HiddenMarkovModel(int theStates, int theItems)`
    `HiddenMarkovModel(int theStates, int[] theItems)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `HiddenMarkovModel` | `clone()`
    `HiddenMarkovModel` | `cloneStructure()`
    `StateDistribution` | `createNewDistribution()`
    `int[]` | `getItems()`
    `double[]` | `getPi()`
    `double` | `getPi(int i)`
    `int` | `getStateCount()`
    `StateDistribution` | `getStateDistribution(int i)`
    `int[]` | `getStatesForSequence(MLDataSet seq)` Get the sates for the given sequence.
    `double[][]` | `getTransitionProbability()`
    `double` | `getTransitionProbability(int i, int j)`
    `boolean` | `isContinuous()`
    `boolean` | `isDiscrete()`
    `double` | `lnProbability(MLDataSet seq)`
    `double` | `probability(MLDataSet seq)` Determine the probability of the specified sequence.
    `double` | `probability(MLDataSet seq, int[] states)` Determine the probability for the specified sequence and states.
    `void` | `setPi(double[] data)`
    `void` | `setPi(int i, double value)`
    `void` | `setStateDistribution(int i, StateDistribution dist)`
    `void` | `setTransitionProbability(double[][] data)`
    `void` | `setTransitionProbability(int i, int j, double value)`
    `void` | `updateProperties()` Update any objeccts when a property changes.

    - ### Methods inherited from class org.encog.ml.BasicML

      `getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TAG_STATES

          public static final String TAG_STATES

      See Also:
        Constant Field Values

    - #### TAG_ITEMS

          public static final String TAG_ITEMS

      See Also:
        Constant Field Values

    - #### TAG_PI

          public static final String TAG_PI

      See Also:
        Constant Field Values

    - #### TAG_TRANSITION

          public static final String TAG_TRANSITION

      See Also:
        Constant Field Values

    - #### TAG_DIST_TYPE

          public static final String TAG_DIST_TYPE

      See Also:
        Constant Field Values

    - #### TAG_MEAN

          public static final String TAG_MEAN

      See Also:
        Constant Field Values

    - #### TAG_COVARIANCE

          public static final String TAG_COVARIANCE

      See Also:
        Constant Field Values

    - #### TAG_PROBABILITIES

          public static final String TAG_PROBABILITIES

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HiddenMarkovModel

          public HiddenMarkovModel(int states)

      Construct a discrete HMM with the specified number of states.
      Parameters:
        `states` - The number of states.

    - #### HiddenMarkovModel

          public HiddenMarkovModel(int theStates,
                           int theItems)

    - #### HiddenMarkovModel

          public HiddenMarkovModel(int theStates,
                           int[] theItems)

  - ### Method Detail

    - #### clone

          public HiddenMarkovModel clone()
                                  throws CloneNotSupportedException

      Overrides:
        `clone` in class `Object`
      Throws:
        `CloneNotSupportedException`

    - #### cloneStructure

          public HiddenMarkovModel cloneStructure()

    - #### createNewDistribution

          public StateDistribution createNewDistribution()

    - #### getPi

          public double getPi(int i)

    - #### getStateCount

          public int getStateCount()

    - #### getStateDistribution

          public StateDistribution getStateDistribution(int i)

    - #### getStatesForSequence

          public int[] getStatesForSequence(MLDataSet seq)

      Description copied from interface: `MLStateSequence`
      Get the sates for the given sequence.
      Specified by:
        `getStatesForSequence` in interface `MLStateSequence`
      Parameters:
        `seq` - The sequence.
      Returns:
        The states.

    - #### getTransitionProbability

          public double getTransitionProbability(int i,
                                        int j)

    - #### isContinuous

          public boolean isContinuous()

    - #### isDiscrete

          public boolean isDiscrete()

    - #### lnProbability

          public double lnProbability(MLDataSet seq)

    - #### probability

          public double probability(MLDataSet seq)

      Description copied from interface: `MLStateSequence`
      Determine the probability of the specified sequence.
      Specified by:
        `probability` in interface `MLStateSequence`
      Parameters:
        `seq` - The sequence.
      Returns:
        The probability.

    - #### probability

          public double probability(MLDataSet seq,
                           int[] states)

      Description copied from interface: `MLStateSequence`
      Determine the probability for the specified sequence and states.
      Specified by:
        `probability` in interface `MLStateSequence`
      Parameters:
        `seq` - The sequence.
        `states` - The states.
      Returns:
        The probability.

    - #### setPi

          public void setPi(int i,
                   double value)

    - #### setStateDistribution

          public void setStateDistribution(int i,
                                  StateDistribution dist)

    - #### setTransitionProbability

          public void setTransitionProbability(int i,
                                      int j,
                                      double value)

    - #### updateProperties

          public void updateProperties()

      Description copied from interface: `MLProperties`
      Update any objeccts when a property changes.
      Specified by:
        `updateProperties` in interface `MLProperties`
      Specified by:
        `updateProperties` in class `BasicML`

    - #### getItems

          public int[] getItems()

    - #### getPi

          public double[] getPi()

    - #### getTransitionProbability

          public double[][] getTransitionProbability()

    - #### setTransitionProbability

          public void setTransitionProbability(double[][] data)

    - #### setPi

          public void setPi(double[] data)

Copyright © 2014. All Rights Reserved.