LinearDynamicalSystem dlm = new LinearDynamicalSystem(
MatrixFactory.getDefault().copyArray(new double[][] {{truePsi.getElement(1)}}),
MatrixFactory.getDefault().copyArray(new double[][] {{1d}}),
MatrixFactory.getDefault().copyArray(new double[][] {{1d}})
);
KalmanFilter trueKf = new KalmanFilter(dlm, modelCovariance, measurementCovariance);
trueKf.setCurrentInput(VectorFactory.getDefault().copyValues(truePsi.getElement(0)));
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 phiMean = VectorFactory.getDefault().copyArray(new double[] {
0d, 0.8d
});
final Matrix phiCov = MatrixFactory.getDefault().copyArray(new double[][] {
{2d + 4d * sigmaPriorMean, 0d},
{ 0d, 4d * sigmaPriorMean}
});
final MultivariateGaussian phiPrior = new MultivariateGaussian(phiMean, phiCov);
final int K = 3;
final int T = 200;
final int N = 1000;
final GaussianArHpWfPlFilter wfFilter =
new GaussianArHpWfPlFilter(trueKf, sigmaPrior, phiPrior, random, K, true);
/*
* Note: replications are over the same set of simulated observations.
*/
List<SimObservedValue<Vector, Matrix, Vector>> simulations = DlmUtils.sampleDlm(
random, T, trueKf.createInitialLearnedObject(), trueKf);
wfFilter.setNumParticles(N);
// log.info("rep\tt\tfilter.type\tmeasurement.type\tresample.type\tmeasurement");