final MultivariateGaussian phiPrior2 = new MultivariateGaussian(phiMean2, phiCov2);
List<MultivariateGaussian> priorPhis = Lists.newArrayList(phiPrior1, phiPrior2);
final HmmPlFilter<DlmHiddenMarkovModel, GaussianArHpTransitionState, Vector> wfFilter =
new GaussianArHpHmmPLFilter(trueHmm1, sigmaPrior, priorPhis, random, true);
final String path;
if (args.length == 0)
path = ".";
else
path = args[0];
String outputFilename = path + "/hmm-nar-wf-rs-10000-class-errors-m1.csv";
final int K = 5;
final int T = 700;
final int N = 1000;
/*
* Note: replications are over the same set of simulated observations.
*/
List<SimHmmObservedValue<Vector, Vector>> simulation = trueHmm1.sample(random, T);
wfFilter.setNumParticles(N);
wfFilter.setResampleOnly(false);
CSVWriter writer = new CSVWriter(new FileWriter(outputFilename), ',');
String[] header = "rep,t,filter.type,measurement.type,resample.type,measurement".split(",");
writer.writeNext(header);
GaussianArHmmClassEvaluator wfClassEvaluator = new GaussianArHmmClassEvaluator("wf-pl",
writer);
GaussianArHmmRmseEvaluator wfRmseEvaluator = new GaussianArHmmRmseEvaluator("wf-pl",
writer);
GaussianArHmmPsiLearningEvaluator wfPsiEvaluator = new GaussianArHmmPsiLearningEvaluator("wf-pl",
truePsis, writer);
RingAccumulator<MutableDouble> wfLatency =
new RingAccumulator<MutableDouble>();
Stopwatch wfWatch = new Stopwatch();
for (int k = 0; k < K; k++) {
log.info("Processing replication " + k);
CountedDataDistribution<GaussianArHpTransitionState> wfDistribution =
(CountedDataDistribution<GaussianArHpTransitionState>) wfFilter.getUpdater().createInitialParticles(N);
final long numPreRuns = -1l;//wfDistribution.getMaxValueKey().getTime();
/*
* Recurse through the particle filter
*/
for (int i = 0; i < T; i++) {
final double x = simulation.get(i).getClassId();
final Vector y = simulation.get(i).getObservedValue();
if (i > numPreRuns) {
if (i > 0) {
wfWatch.reset();
wfWatch.start();
wfFilter.update(wfDistribution, simulation.get(i));
wfWatch.stop();
final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
wfLatency.accumulate(new MutableDouble(latency));
writer.writeNext(new String[] {
Integer.toString(k), Integer.toString(i),