Package gov.sandia.cognition.math

Examples of gov.sandia.cognition.math.MutableDouble


        stateMean.accumulate(gParticle.getState().getMean().scale(particleWeight));
      }
    }

    final double rmse = stateMean.getSum().minus(trueState).norm2();
    runningRate.accumulate(new MutableDouble(rmse));

    if (writer != null) {
      String[] line = {
          Integer.toString(replication),
          Long.toString(obs.getTime()),
View Full Code Here


    final double x = obs.getClassId();
    RingAccumulator<MutableDouble> classificationRate = new RingAccumulator<MutableDouble>();
    for (T state : distribution.getDomain()) {
      final double wfErr = (x == state.getClassId()) ?
          distribution.getFraction(state) : 0d;
      classificationRate.accumulate(new MutableDouble(wfErr));
    }

    runningRate.accumulate(new MutableDouble(classificationRate.getSum()));

    ResampleType resampleType = distribution.getMaxValueKey().getResampleType();
    String[] wfClassLine = {
        Integer.toString(replication),
        Long.toString(obs.getTime()),
View Full Code Here

          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),
              "mkf", "latency", "NA",
              Long.toString(latency)
          });
        }

        if (i > numPreRuns) {

          if (i > 0) {
            wfWatch.reset();
            wfWatch.start();
            wfFilter.update(wfDistribution, obsState);
            wfWatch.stop();
            final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
            wfLatency.accumulate(new MutableDouble(latency));
            writer.writeNext(new String[] {
                Integer.toString(k), Integer.toString(i),
                "wf-pl", "latency", "NA",
                Long.toString(latency)
            });
View Full Code Here

            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),
                "wf-pl", "latency", "NA",
                Long.toString(latency)
            });
View Full Code Here

           * Recurse through the particle filter
           */
          for (int i = 0; i < T; i++) {
     
            final double x = DoubleMath.roundToInt(samples.get(i).getState(), RoundingMode.HALF_EVEN);
            viterbiRate.accumulate(new MutableDouble((x == viterbiResults.get(i) ? 1d : 0d)));
   
            final T y = samples.get(i).getObservedValue();
            final ObservedValue<T, Void> obsState = ObservedValue.create(i, y);
   
            rsFilter.update(rsDistribution, obsState);
   
            /*
             * Compute and output RS forward errors
             */
            ResampleType rsResampleType = rsDistribution.getMaxValueKey().getResampleType();
            Vector rsStateProbDiffs = computeStateDiffs(i, hmm.getNumStates(), rsDistribution, forwardResults);
            String[] rsLine = {Integer.toString(k), Integer.toString(i), "p(x_t=0|y^t)",
               rsResampleType.toString(),
               Double.toString(rsStateProbDiffs.getElement(0))};
            writer.writeNext(rsLine);
            log.info("rsStateProbDiffs=" + rsStateProbDiffs);
   
     
            if (i > numPreRuns) {
              wfFilter.update(wfDistribution, obsState);
       
              RingAccumulator<MutableDouble> pfAtTRate = new RingAccumulator<MutableDouble>();
              for (P state : wfDistribution.getDomain()) {
                final double err = (x == state.getClassId()) ? wfDistribution.getFraction(state) : 0d;
                pfAtTRate.accumulate(new MutableDouble(err));
              }
              pfRunningRate.accumulate(new MutableDouble(pfAtTRate.getSum()));
       
              ResampleType wfResampleType = wfDistribution.getMaxValueKey().getResampleType();
              Vector wfStateProbDiffs = computeStateDiffs(i, hmm.getNumStates(), wfDistribution, forwardResults);
              String[] wfLine = {Integer.toString(k), Integer.toString(i), "p(x_t=0|y^t)", "water-filling",
                 wfResampleType.toString(),
View Full Code Here

            wfWatch.reset();
            wfWatch.start();
            wfFilter.update(wfDistribution, simulations.get(i));
            wfWatch.stop();
            final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
            wfLatency.accumulate(new MutableDouble(latency));
          }
         
          wfEvaluator.evaluate(k, simulations.get(i), wfDistribution);
        }

        if ((i+1) % (T/4d) < 1) {
          log.info(Joiner.on("\t").join(new String[] {
              Integer.toString(k),
              Integer.toString(i),
              Double.toString(wfLatency.getMean().value),
              Double.toString(wfEvaluator.getStateLastRmse()),
              Double.toString(wfEvaluator.getSigma2LastRmse()),
              Double.toString(wfEvaluator.getPsiLastRmse())
//              Double.toString(wfEvaluator.getRunningStateRmse()),
//              Double.toString(wfEvaluator.getRunningSigma2Rmse()),
//              Double.toString(wfEvaluator.getRunningPsiRmse())
              }));
          log.info(Joiner.on("\t").join(new String[] {
              Integer.toString(k),
              Integer.toString(i),
              Double.toString(wfLatency.getMean().value),
              "% " + Double.toString(wfEvaluator.getStateLastErrRate()),
              "% " + Double.toString(wfEvaluator.getSigma2LastErrRate()),
              "% " + Double.toString(wfEvaluator.getPsiLastErrRate())
//              Double.toString(wfEvaluator.getRunningStateErrRate()),
//              Double.toString(wfEvaluator.getRunningSigma2ErrRate()),
//              Double.toString(wfEvaluator.getRunningPsiErrRate())
              }));
        }
      }
      wfStateRMSEs.accumulate(new MutableDouble(wfEvaluator.getStateLastErrRate()));
      wfPsiRMSEs.accumulate(new MutableDouble(wfEvaluator.getPsiLastErrRate()));
      wfSigma2RMSEs.accumulate(new MutableDouble(wfEvaluator.getSigma2LastErrRate()));

    }

    assertEquals(0d, wfStateRMSEs.getMean().doubleValue(), 1d/Math.sqrt(N));
  }
View Full Code Here

            wfWatch.reset();
            wfWatch.start();
            wfFilter.update(wfDistribution, simulation.get(i));
            wfWatch.stop();
            final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
            wfLatency.accumulate(new MutableDouble(latency));
            log.info(Joiner.on("\t").join(new String[] {
                Integer.toString(k), Integer.toString(i),
                "wf-pl", "latency", "NA",
                Long.toString(latency)})
                );
View Full Code Here

            wfWatch.reset();
            wfWatch.start();
            wfFilter.update(wfDistribution, simulation.get(i));
            wfWatch.stop();
            final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
            wfLatency.accumulate(new MutableDouble(latency));
            log.info(Joiner.on("\t").join(new String[] {
                Integer.toString(k), Integer.toString(i),
                "wf-pl", "latency", "NA",
                Long.toString(latency)})
                );
View Full Code Here

            wfWatch.reset();
            wfWatch.start();
            wfFilter.update(wfDistribution, simulations.get(i));
            wfWatch.stop();
            final long latency = wfWatch.elapsed(TimeUnit.MILLISECONDS);
            wfLatency.accumulate(new MutableDouble(latency));
          }
         
          wfEvaluator.evaluate(k, simulations.get(i), wfDistribution);
        }

        if ((i+1) % (T/4d) < 1) {
          log.info(Joiner.on("\t").join(new String[] {
              Integer.toString(k),
              Integer.toString(i),
              Double.toString(wfLatency.getMean().value),
              Double.toString(wfEvaluator.getStateLastRmse()),
              Double.toString(wfEvaluator.getSigma2LastRmse()),
              Double.toString(wfEvaluator.getPsiLastRmse())
              }));
          log.info(Joiner.on("\t").join(new String[] {
              Integer.toString(k),
              Integer.toString(i),
              Double.toString(wfLatency.getMean().value),
              "% " + Double.toString(wfEvaluator.getStateLastErrRate()),
              "% " + Double.toString(wfEvaluator.getSigma2LastErrRate()),
              "% " + Double.toString(wfEvaluator.getPsiLastErrRate())
              }));
        }
      }
      wfStateRMSEs.accumulate(new MutableDouble(wfEvaluator.getStateLastErrRate()));
      wfPsiRMSEs.accumulate(new MutableDouble(wfEvaluator.getPsiLastErrRate()));
      wfSigma2RMSEs.accumulate(new MutableDouble(wfEvaluator.getSigma2LastErrRate()));

    }

    writer.close();
  }
View Full Code Here

      MultivariateGaussian psi = gParticle.getPsiSS();
      psiAvg.accumulate(psi.getMean().scale(particleWeight));
     
      double sigma2Mean = gParticle.getSigma2SS().getMean();
      sigma2Avg.accumulate(new MutableDouble(sigma2Mean * particleWeight));

    }
   
    this.stateLastMean = stateAvg.getSum();
    this.psiLastMean = psiAvg.getSum();
    this.sigma2LastMean = sigma2Avg.getSum().doubleValue();

    this.stateLastRmse = stateLastMean.minus(obs.getTrueState()).norm2();
    this.psiLastRmse = psiLastMean.minus(this.truePsi).norm2();
    this.sigma2LastRmse = Math.abs(this.trueSigma2 - sigma2LastMean);
    runningStateRmse.accumulate(new MutableDouble(stateLastRmse));
    runningPsiRmse.accumulate(new MutableDouble(psiLastRmse));
    runningSigma2Rmse.accumulate(new MutableDouble(sigma2LastRmse));

    this.stateLastErrRate = stateLastRmse/obs.getTrueState().norm2();
    this.psiLastErrRate = psiLastRmse/this.truePsi.norm2();
    this.sigma2LastErrRate = sigma2LastRmse/this.trueSigma2;
    runningStateErrRate.accumulate(new MutableDouble(stateLastErrRate));
    runningPsiErrRate.accumulate(new MutableDouble(psiLastErrRate));
    runningSigma2ErrRate.accumulate(new MutableDouble(sigma2LastErrRate));

    if (writer != null) {
      String[] line = {
          Integer.toString(replication),
          Long.toString(obs.getTime()),
View Full Code Here

TOP

Related Classes of gov.sandia.cognition.math.MutableDouble

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.