.copyArray(new double[] { 0.7d, 0.3d });
Matrix classTransProbs = MatrixFactory.getDefault().copyArray(
new double[][] { { 0.7d, 0.7d },
{ 0.3d, 0.3d } });
DlmHiddenMarkovModel trueHmm1 = new DlmHiddenMarkovModel(
Lists.newArrayList(trueKf1, trueKf2),
initialClassProbs, classTransProbs);
final double sigmaPriorMean = Math.pow(0.4, 2);
final double sigmaPriorShape = 2d;
final double sigmaPriorScale = sigmaPriorMean*(sigmaPriorShape + 1d);
final InverseGammaDistribution sigmaPrior = new InverseGammaDistribution(sigmaPriorShape,
sigmaPriorScale);
final Vector phiMean1 = VectorFactory.getDefault().copyArray(new double[] {
0d, 0.8d
});
final Matrix phiCov1 = MatrixFactory.getDefault().copyArray(new double[][] {
{2d + 4d * sigmaPriorMean, 0d},
{ 0d, 4d * sigmaPriorMean}
});
final MultivariateGaussian phiPrior1 = new MultivariateGaussian(phiMean1, phiCov1);
final Vector phiMean2 = VectorFactory.getDefault().copyArray(new double[] {
0d, 0.1d
});
final Matrix phiCov2 = MatrixFactory.getDefault().copyArray(new double[][] {
{ 1d + 4d * sigmaPriorMean, 0d},
{ 0d, 4d * sigmaPriorMean}
});
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), ',');