Package plm.hmm.gaussian

Examples of plm.hmm.gaussian.GaussianArHmmMkfFilter


            classTransProbs, Lists.newArrayList(
                s1Likelihood, s2Likelihood)));

    final HmmPlFilter<StandardHMM<Double>, GaussianArTransitionState, Double> wfFilter =
        new GaussianArHmmPlFilter(trueHmm1, prior, a, sigma2, sigma_y2, random, true);
    final GaussianArHmmMkfFilter rsFilter =
        new GaussianArHmmMkfFilter(trueHmm1, prior, a, sigma2, sigma_y2, random);


    String outputFilename = args[0] + "/hmm-nar-wf-rs-10000-class-errors-m1.csv";
    final int K = 10;
    final int T = 300;

    List<SimHmmObservedValue<Vector, Vector>> simulation = dlmHmm.sample(random, T);

    wfFilter.setNumParticles(N);
    wfFilter.setResampleOnly(false);
    rsFilter.setNumParticles(N);

    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);
    GaussianArHmmClassEvaluator mkfClassEvaluator = new GaussianArHmmClassEvaluator("mkf",
        writer);
    GaussianArHmmRmseEvaluator wfRmseEvaluator = new GaussianArHmmRmseEvaluator("wf-pl",
        writer);
    GaussianArHmmRmseEvaluator mkfRmseEvaluator = new GaussianArHmmRmseEvaluator("mkf",
        writer);

    RingAccumulator<MutableDouble> mkfLatency =
        new RingAccumulator<MutableDouble>();
    RingAccumulator<MutableDouble> wfLatency =
        new RingAccumulator<MutableDouble>();
    Stopwatch mkfWatch = new Stopwatch();
    Stopwatch wfWatch = new Stopwatch();


    for (int k = 0; k < K; k++) {
      log.info("Processing replication " + k);
      CountedDataDistribution<GaussianArTransitionState> wfDistribution =
          (CountedDataDistribution<GaussianArTransitionState>) wfFilter.getUpdater().createInitialParticles(N);
//          ((HmmPlFilter.HmmPlUpdater<Double>) wfFilter.getUpdater()).baumWelchInitialization(sample.getFirst(), N);

      DataDistribution<GaussianArTransitionState> rsDistribution =
          rsFilter.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 Double y = simulation.get(i).getObservedValue().getElement(0);
        // lame hack need until I refactor to use DlmHiddenMarkovModel in the filters
        final ObservedValue<Double, Void> obsState = new SimHmmObservedValue<Double, Double>(i,
           (int)x , simulation.get(i).getState().getElement(0), y);

        if (i > 0) {
          mkfWatch.reset();
          mkfWatch.start();
          rsFilter.update(rsDistribution, obsState);
          mkfWatch.stop();
          final long latency = mkfWatch.elapsed(TimeUnit.MILLISECONDS);
          mkfLatency.accumulate(new MutableDouble(latency));
          writer.writeNext(new String[] {
              Integer.toString(k), Integer.toString(i),
View Full Code Here

TOP

Related Classes of plm.hmm.gaussian.GaussianArHmmMkfFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.