Package InfoCollection.util

Examples of InfoCollection.util.MeanVariance


   * repeats the experiment, returning a sample average. The other runs the
   * experiment once and returns the loss realized.
   */
  public static double LossAtEnd(SamplingRule policy, Truth truth, int N,
      int nruns) throws Exception {
    MeanVariance lossEstimator = new MeanVariance();
    Random rnd = new Random();
    for (int r = 0; r < nruns; r++) {
      policy.Start(truth.M());
      for (int n = 0; n < N; n++) {
        int x = policy.GetMeasurementDecision();
        double y = truth.Sample(x, rnd);
        policy.RecordMeasurement(x, y);
      }
      int i = policy.GetImplementationDecision();
      lossEstimator.AddSample(truth.Loss(i));
    }
    return lossEstimator.SampleMean();
  }
View Full Code Here


   * from the belief b. Also note that it returns a MeanVariance, rather than
   * just the sample average.
   */
  public static MeanVariance LossAtEnd(SamplingRule policy, Belief b, int N,
      int nruns) throws Exception {
    MeanVariance lossEstimator = new MeanVariance();
    Random rnd = new Random();
    for (int r = 0; r < nruns; r++) {
      Truth truth = b.GenerateTruth(rnd);
      policy.Start(truth.M());
      for (int n = 0; n < N; n++) {
        int x = policy.GetMeasurementDecision();
        double y = truth.Sample(x, rnd);
        policy.RecordMeasurement(x, y);
      }
      int i = policy.GetImplementationDecision();
      lossEstimator.AddSample(truth.Loss(i));
    }
    return lossEstimator;
  }
View Full Code Here

    MeanVariance[] loss = new MeanVariance[stop.Length()];
    MeanVariance[] N = new MeanVariance[stop.Length()];
    double[][] result = new double[stop.Length()][5];
    for (s = 0; s < stop.Length(); s++) {
      timeouts[s] = 0;
      loss[s] = new MeanVariance();
      N[s] = new MeanVariance();
    }

    Random rnd = new Random();
    for (r = 0; r < nruns; r++) {
      policy.Start(truth.M());
View Full Code Here

    MeanVariance[] loss = new MeanVariance[stop.Length()];
    MeanVariance[] N = new MeanVariance[stop.Length()];
    double[][] result = new double[stop.Length()][5];
    for (s = 0; s < stop.Length(); s++) {
      timeouts[s] = 0;
      loss[s] = new MeanVariance();
      N[s] = new MeanVariance();
    }

    Random rnd = new Random();
    for (r = 0; r < nruns; r++) {
      Truth truth = prior.GenerateTruth(rnd);
View Full Code Here

  // that class.
  public MeanVariance EOCBayesMC(int nsamples, Random rnd)
      throws NotInformativeException {
    // int M = mu.length;
    // double[] values = new double[M];
    MeanVariance ans = new MeanVariance();
    double maxmu = MathPF.max(mu);
    for (int s = 0; s < nsamples; s++) {
      Truth truth = GenerateTruth(rnd);
      ans.AddSample(truth.BestValue() - maxmu);
    }
    return ans;
  }
View Full Code Here

    /* Evaluate using numerical integration and monte carlo. */
    double EOCBayesAns = EOCBayes();
    int mcsamples = 1000000;
    try {
      MeanVariance MCAns = EOCBayesMC(mcsamples);

      /* Get the t-statistic and report the result. */
      double t = (EOCBayesAns - MCAns.SampleMean())
          / MCAns.SampleMeanDeviation();
      if (verbose)
        System.out.printf(
            "EOCBayes Answer=%f, MonteCarlo Answer=%f, t=%f\n",
            EOCBayesAns, MCAns, t);
      return t;
View Full Code Here

   * Tests that the computation of sigmahat is correct.
   */
  public static boolean test1() {
    try {
      int N = 1000;
      MeanVariance mv = new MeanVariance();
      Random rnd = new Random();
      Belief b = new Belief(1);
      for (int n = 0; n < N; n++) {
        double data = rnd.nextGaussian();
        b.Update(0, data);
        mv.AddSample(data);
      }
      /*
       * Now, SampleVarianceMSE(), which computes sigmahat^2, should be
       * equal to sigmahat^2 as computed by Belief.
       */
      double mv_val = mv.SampleVarianceMSE();
      double b_val = b.sigmahat2(0);
      int ulps = MathPF.FloatCmp(mv_val, b_val);
      boolean ok = ulps < 30;
      System.out.printf("test1: diff/ulp=%d (true)variance=1 "
          + "MeanVariance.sigmahat=%.3f belief.sigmahat=%.3f\n",
          ulps, mv.SampleVarianceMSE(), b.sigmahat2(0));
      if (ok)
        System.out.println("test1: OK");
      else
        System.out.println("test1: FAILED");
      return ok;
View Full Code Here

TOP

Related Classes of InfoCollection.util.MeanVariance

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.