/// <summary> /// Predicts the next observation occurring after a given observation sequence. /// </summary> /// public double[] Predict(double[] observations, int next, out double logLikelihood) { if (multivariate) { throw new ArgumentException("Model is multivariate.", "observations"); } if (observations == null) { throw new ArgumentNullException("observations"); } // Convert to multivariate observations double[][] obs = MarkovHelperMethods.convertNoCheck(observations, dimension); // Matrix to store the probabilities in assuming the next // observations (prediction) will belong to each state. double[][] weights; // Compute the next observations double[][] prediction = predict(obs, next, out logLikelihood, out weights); // Return the first (single) dimension of the next observations. return(Accord.Math.Matrix.Concatenate(prediction)); }
/// <summary> /// Predicts the next observation occurring after a given observation sequence. /// </summary> /// public double Predict(double[] observations, out double logLikelihood) { if (multivariate) { throw new ArgumentException("Model is multivariate.", "observations"); } if (observations == null) { throw new ArgumentNullException("observations"); } // Convert to multivariate observations double[][] obs = MarkovHelperMethods.convertNoCheck(observations, dimension); // Matrix to store the probabilities in assuming the next // observations (prediction) will belong to each state. double[][] weights; // Compute the next observation (currently only one ahead is supported). double[][] prediction = predict(obs, 1, out logLikelihood, out weights); return(prediction[0][0]); }
/// <summary> /// Predicts the next observation occurring after a given observation sequence. /// </summary> /// private double[] predict <TUnivariate>(double[] observations, out double logLikelihood, out Mixture <TUnivariate> probabilities) where TUnivariate : DistributionBase, TDistribution, IUnivariateDistribution { // Convert to multivariate observations double[][] obs = MarkovHelperMethods.convertNoCheck(observations, dimension); // Matrix to store the probabilities in assuming the next // observations (prediction) will belong to each state. double[][] weights; // Compute the next observation (currently only one ahead is supported). double[][] prediction = predict(obs, 1, out logLikelihood, out weights); // Create the mixture distribution defining the model likelihood in // assuming the next observation belongs will belong to each state. TUnivariate[] b = Array.ConvertAll(B, x => (TUnivariate)x); probabilities = new Mixture <TUnivariate>(weights[1].Exp(), b); return(prediction[0]); }