package ac.essex.gp.markov;

import java.util.Vector;

/**
 * The Hidden Markov Model allows us to predict emergent behaviours, based on the
 * observation of measurable events.
 *
 * Since the underlying system may not be directly observable, we need to determine
 * its probability, based on the real events that can be observed.
 *
 * The Markov Assumption - that the state of a system depends only upon the previous
 * states of the system.
 *
 * A Markov Process consists of:
 * - States
 * - A Pi Vector defining the probability of the system being in each of the states at time 0
 * - A State transition matrix - the probability of the weather changing given the previous day's weather.
 *
 *
 * @author Olly Oechsle, University of Essex, Date: 05-Mar-2007
 * @version 1.0
 */
public class HiddenMarkovModel {

    /**
     * Hidden states
     */
    protected Vector<HiddenState> hiddenStates;

    /**
     * Observed states
     */
    protected Vector<ObservedState> observedStates;

    /**
     * A Pi Vector stores the initial probabilities
     * so we know what state we're starting from.
     */
    protected PiVector initialProbabilities;

    /**
     * The probabilities of one state changing to another
     * based on a first order Markov process.
     */
    protected StateTransitionMatrix stateTransitionMatrix;

    /**
     * Maps the probabilities that a given *hidden* state will produce
     * a certain observable outcome.
     */
    protected ConfusionMatrix confusionMatrix;


    /**
     * Initialises the Hidden Markov Model with the required data.
     * @param hiddenStates A vector of the different hidden states
     * @param observedStates A vector of the different observable states
     * @param initialProbabilities A vector of the likely initial probabilities of the hidden states
     * @param stateTransitionMatrix A matrix of the probabilities that a given hidden state will transition to another.
     * @param confusionMatrix A matrix of the probabilities that a given observable state is caused by a hidden state.
     */
    public HiddenMarkovModel(Vector<HiddenState> hiddenStates, Vector<ObservedState> observedStates, PiVector initialProbabilities, StateTransitionMatrix stateTransitionMatrix, ConfusionMatrix confusionMatrix) {
        this.hiddenStates = hiddenStates;
        this.observedStates = observedStates;
        this.initialProbabilities = initialProbabilities;
        this.stateTransitionMatrix = stateTransitionMatrix;
        this.confusionMatrix = confusionMatrix;
    }

}
