- centeringDist.getInputDimensionality() + 1d;
final double kappa = centeringDist.getCovarianceDivisor();
final Matrix newComponentPriorPredPrecision =
centeringDist.getInverseWishart().getInverseScale()
.scale(2d * (kappa + 1d) / (kappa * newComponentPriorPredDof));
final MultivariateStudentTDistribution newComponentPriorPred =
new MultivariateStudentTDistribution(newComponentPriorPredDof, centeringDist
.getGaussian().getMean(), newComponentPriorPredPrecision.inverse());
final double newComponentLogLikelihood =
Math.log(particle.getAlpha()) - Math.log(particle.getAlpha() + particle.getIndex())
+ newComponentPriorPred.getProbabilityFunction().logEvaluate(observation);
componentPriorPredLogLikelihoods[0] = newComponentLogLikelihood;
double totalLogLikelihood = newComponentLogLikelihood;
/*
* Now, evaluate log likelihood for the current mixture components
*/
int n = 0;
for (final MultivariateGaussian component : particle.getDistributions()) {
final double componentN = particle.getCounts().getElement(n);
final double componentPriorPredDof =
2d * centeringDist.getInverseWishart().getDegreesOfFreedom() + componentN
- centeringDist.getInputDimensionality() + 1d;
final Vector componentPriorPredMean =
centeringDist.getGaussian().getMean().scale(kappa)
.plus(component.getMean().scale(componentN)).scale(1d / (kappa + componentN));
final Vector componentCenteringMeanDiff =
centeringDist.getGaussian().getMean().minus(component.getMean());
final Matrix componentD =
component.getCovariance().plus(
componentCenteringMeanDiff.outerProduct(componentCenteringMeanDiff).scale(
kappa * componentN / (kappa + componentN)));
final Matrix componentPriorPredCovariance =
centeringDist
.getInverseWishart()
.getInverseScale()
.plus(componentD.scale(1d / 2d))
.scale(
2d * (kappa + componentN + 1d) / ((kappa + componentN) * componentPriorPredDof));
// FIXME TODO avoid this inverse!
final MultivariateStudentTDistribution componentPriorPred =
new MultivariateStudentTDistribution(componentPriorPredDof, componentPriorPredMean,
componentPriorPredCovariance.inverse());
final double componentLogLikelihood =
Math.log(componentN) - Math.log(particle.getAlpha() + particle.getIndex())
+ componentPriorPred.getProbabilityFunction().logEvaluate(observation);
componentPriorPredLogLikelihoods[n + 1] = componentLogLikelihood;
totalLogLikelihood = LogMath.add(totalLogLikelihood, componentLogLikelihood);
n++;
}