Accord.NET Framework

## HiddenMarkovModelTDistribution, TObservationPredictTMultivariate Method (TObservation, MultivariateMixtureTMultivariate) |

Predicts the next observation occurring after a given observation sequence.

Syntax

public TObservation Predict<TMultivariate>( TObservation[] observations, out MultivariateMixture<TMultivariate> probabilities ) where TMultivariate : IMultivariateDistribution<double[]>

- observations
- Type: TObservation

A sequence of observations. Predictions will be made regarding the next observations that should be coming after the last observation in this sequence. - probabilities
- Type: Accord.Statistics.Distributions.MultivariateMultivariateMixtureTMultivariate

The continuous probability distribution describing the next observations that are likely to be generated. Taking the mode of this distribution might give the most likely next value in the observed sequence.

- TMultivariate

Remarks

This method works by inspecting the forward matrix of probabilities for the sequence and
checking which would be the most likely state after the current one. Then, it returns the
most likely value (the mode) for the distribution associated with that state. This limits
the applicability of this model to only very short-term predictions (i.e. most likely, only
the most immediate next observation).

Examples

// We will try to create a Hidden Markov Model which // can recognize (and predict) the following sequences: double[][] sequences = { new double[] { 1, 3, 5, 7, 9, 11, 13 }, new double[] { 1, 3, 5, 7, 9, 11 }, new double[] { 1, 3, 5, 7, 9, 11, 13 }, new double[] { 1, 3, 3, 7, 7, 9, 11, 11, 13, 13 }, new double[] { 1, 3, 7, 9, 11, 13 }, }; // Create a Baum-Welch HMM algorithm: var teacher = new BaumWelchLearning<NormalDistribution, double, NormalOptions>() { // Let's creates a left-to-right (forward) // Hidden Markov Model with 7 hidden states Topology = new Forward(7), FittingOptions = new NormalOptions() { Regularization = 1e-8 }, // We'll try to fit the model to the data until the difference in // the average log-likelihood changes only by as little as 0.0001 Tolerance = 0.0001, Iterations = 0 // do not impose a limit on the number of iterations }; // Use the algorithm to learn a new Markov model: HiddenMarkovModel<NormalDistribution, double> hmm = teacher.Learn(sequences); // Now, we will try to predict the next 1 observation in a base symbol sequence double[] prediction = hmm.Predict(observations: new double[] { 1, 3, 5, 7, 9 }, next: 1); // At this point, prediction should be around double[] { 11.909090909090905 } double nextObservation = prediction[0]; // should be comparatively near 11.

See Also