/** * Predict the log-posterior for the given sample; this is the * log-probability of the sample point belonging to each of the gaussians in * the mixture. * * @param sample * the sample * @return the log-probability for each gaussian */ public double[] predictLogPosterior(double[] sample) { return predictLogPosterior(new double[][] { sample })[0]; }
/** * Predict the class (the index of the most-probable gaussian) to which the * given data point belongs. * * @param data * the data point * @return the class index */ public int predict(double[] data) { final double[] posterior = predictLogPosterior(data); return ArrayUtils.maxIndex(posterior); } }