/*
* The following are the parameter learning updates;
* they can be done off-line, but we'll do them now.
* TODO FIXME check that the input/offset thing is working!
*/
final InverseGammaDistribution invScaleSS = predState.getInvScaleSS().clone();
final List<MultivariateGaussian> systemOffsetsSS =
ObjectUtil.cloneSmartElementsAsArrayList(predState.getPsiSS());
final int xDim = posteriorState.getInputDimensionality();
final Matrix Ij = MatrixFactory.getDefault().createIdentity(xDim, xDim);
final Matrix H = MatrixFactory.getDefault().createMatrix(xDim, xDim * 2);
H.setSubMatrix(0, 0, Ij);
H.setSubMatrix(0, xDim, MatrixFactory.getDefault().createDiagonal(predState.getStateSample()));
final Vector postStateSample = posteriorState.sample(this.rng);
final MultivariateGaussian priorPhi = predState.getPsiSS().get(predState.getClassId());
final Vector phiPriorSmpl = priorPhi.sample(this.rng);
final Vector xHdiff = postStateSample.minus(H.times(phiPriorSmpl));
final double newN = invScaleSS.getShape() + 1d;
final double d = invScaleSS.getScale() + xHdiff.dotProduct(xHdiff);
invScaleSS.setScale(d);
invScaleSS.setShape(newN);
// FIXME TODO: crappy sampler
final double newInvScaleSmpl = invScaleSS.sample(this.rng);
/*
* Update state and measurement covariances, which
* have a strict dependency in this model (equality).
*/