package ac.essex.gp.markov;

import java.util.Vector;

/**
 *
 * The probability of an observation given a hidden state is provided
 * by the confusion matrix.
 *
 * @author Olly Oechsle, University of Essex, Date: 05-Mar-2007
 * @version 1.0
 */
public class ConfusionMatrix {

    protected double[][] probabilities;

    public ConfusionMatrix(Vector<HiddenState> hiddenStates, Vector<ObservedState> observedStates) {
        probabilities = new double[hiddenStates.size()][observedStates.size()];
    }

    public void setProbability(HiddenState hidden, ObservedState observed, double probability) {
        probabilities[hidden.id][observed.id] = probability;
    }

    /**
     * Gets the probability that the observed state is caused by the hidden state.
     * For example, the hidden state "sunny" may well give a high probability that the observed state "dryness" will be true. 
     */
    public double getProbability(HiddenState hidden, ObservedState observed) {
        return probabilities[hidden.id][observed.id];
    }

}
