CountedDataDistribution.create(numParticles, true);
for (int i = 0; i < numParticles; i++) {
final InverseGammaDistribution thisPriorScale = this.initialPriorSigma2.clone();
final KalmanFilter thisKf = this.initialKf.clone();
/*
* In this model, covariance is the same across components;
* the constant offset varies.
* As well, we need to set/reset the kalman filters to adhere
* to the intended model.
*/
final double scaleSample = thisPriorScale.sample(this.rng);
final MultivariateGaussian thisPriorOffset = initialPriorPsi.clone();
final Vector systemSample = thisPriorOffset.sample(this.rng);
final Vector offsetTerm = systemSample.subVector(0,
systemSample.getDimensionality()/2 - 1);
thisKf.getModel().setState(offsetTerm);
thisKf.setCurrentInput(offsetTerm);
final Matrix A = MatrixFactory.getDefault().createDiagonal(
systemSample.subVector(
systemSample.getDimensionality()/2,
systemSample.getDimensionality() - 1));
thisKf.getModel().setA(A);
final Matrix offsetIdent = MatrixFactory.getDefault().createIdentity(
systemSample.getDimensionality()/2, systemSample.getDimensionality()/2);
thisKf.getModel().setB(offsetIdent);
final Matrix measIdent = MatrixFactory.getDefault().createIdentity(
thisKf.getModel().getOutputDimensionality(),
thisKf.getModel().getOutputDimensionality());
thisKf.setMeasurementCovariance(measIdent.scale(scaleSample));
final Matrix modelIdent = MatrixFactory.getDefault().createIdentity(
thisKf.getModel().getStateDimensionality(),
thisKf.getModel().getStateDimensionality());
thisKf.setModelCovariance(modelIdent.scale(scaleSample));
final MultivariateGaussian priorState = thisKf.createInitialLearnedObject();
final Vector priorStateSample = priorState.sample(this.rng);
final GaussianArHpWfParticle particle =
new GaussianArHpWfParticle(thisKf,
ObservedValue.<Vector>create(0, null), priorState,