package ac.essex.gp.markov;

import java.util.Vector;

/**
  * A Markov process is a process which moves from state to state
  * depending only on the previous n states. This is called an order n model. The simplest
  * is a first order process where the choice of state is made purely
  * on the basis of the previous state.
  *
  * For a first order process with M states, there are M^2 transitions between
  * states as it is possible for any one state to follow another. Associated
  * with each transition is a probability, called the state transition probability.
  * These probabilities are collected into a state transition matrix.
 *
 * @author Olly Oechsle, University of Essex, Date: 05-Mar-2007
 * @version 1.0
 */
public class StateTransitionMatrix {

    protected double[][] probabilities;

    public StateTransitionMatrix(Vector<HiddenState> states) {
        final int size = states.size();
        probabilities = new double[size][size];
    }

    public void setProbability(HiddenState from, HiddenState to, double probability) {
        probabilities[from.id][to.id] = probability;
    }

    public double getProbability(HiddenState from, HiddenState to) {
        return probabilities[from.id][to.id];
    }

}
