}
});
for (Entry<LogitPGParticle, ? extends Number> particleEntry : target.asMap().entrySet()) {
final LogitPGParticle particle = particleEntry.getKey();
final MultivariateGaussian predictivePrior = particle.getLinearState().clone();
KalmanFilter kf = particle.getRegressionFilter();
final Matrix G = kf.getModel().getA();
final Matrix F = data.getObservedData();
predictivePrior.setMean(G.times(predictivePrior.getMean()));
predictivePrior.setCovariance(
G.times(predictivePrior.getCovariance()).times(G.transpose())
.plus(kf.getModelCovariance()));
final Vector betaMean = predictivePrior.getMean();
final double k_t = data.getObservedValue().getElement(0) - 1d/2d;
final int particleCount;
if (particleEntry.getValue() instanceof MutableDoubleCount) {
particleCount = ((MutableDoubleCount)particleEntry.getValue()).count;
} else {
particleCount = 1;
}
for (int p = 0; p < particleCount; p++) {
for (int j = 0; j < K; j++) {
/*
* Sample and compute the latent variable...
*/
final double omega = PolyaGammaDistribution.sample(0d, this.getRandom());
final double z_t = k_t / omega;
final LogitPGParticle predictiveParticle = particle.clone();
predictiveParticle.setPreviousParticle(particle);
predictiveParticle.setBetaSample(betaMean);
predictiveParticle.setLinearState(predictivePrior);
predictiveParticle.setAugResponseSample(
VectorFactory.getDefault().copyValues(z_t));
/*
* Update the observed data for the regression component.
*/
predictiveParticle.getRegressionFilter().getModel().setC(F);
final Matrix compVar = MatrixFactory.getDefault().copyArray(
new double[][] {{1d/omega}});
predictiveParticle.getRegressionFilter().setMeasurementCovariance(compVar);
final double compPredPriorObsMean = F.times(betaMean).getElement(0) ;
final double compPredPriorObsCov =
F.times(predictivePrior.getCovariance()).times(F.transpose()).getElement(0, 0)
+ 1d/omega;
predictiveParticle.setPriorPredMean(compPredPriorObsMean);
predictiveParticle.setPriorPredCov(compPredPriorObsCov);
final double logLikelihood =