Package org.apache.commons.math.stat.descriptive

Examples of org.apache.commons.math.stat.descriptive.DescriptiveStatistics


  /**
   * Test StorelessDescriptiveStatistics
   */
  public void testStoredUnivariateImpl() throws Exception {

    DescriptiveStatistics u = DescriptiveStatistics.newInstance();
   
    loadStats("data/PiDigits.txt", u);
    assertEquals("PiDigits: std", std, u.getStandardDeviation(), .0000000000001);
    assertEquals("PiDigits: mean", mean, u.getMean(), .0000000000001);
   
    loadStats("data/Mavro.txt", u);
    assertEquals("Mavro: std", std, u.getStandardDeviation(), .00000000000001);
    assertEquals("Mavro: mean", mean, u.getMean(), .00000000000001);   
   
    //loadStats("data/Michelso.txt");
    //assertEquals("Michelso: std", std, u.getStandardDeviation(), .00000000000001);
    //assertEquals("Michelso: mean", mean, u.getMean(), .00000000000001); 

    loadStats("data/NumAcc1.txt", u);
    assertEquals("NumAcc1: std", std, u.getStandardDeviation(), .00000000000001);
    assertEquals("NumAcc1: mean", mean, u.getMean(), .00000000000001);
   
    //loadStats("data/NumAcc2.txt");
    //assertEquals("NumAcc2: std", std, u.getStandardDeviation(), .000000001);
    //assertEquals("NumAcc2: mean", mean, u.getMean(), .00000000000001);
  }
View Full Code Here


   * @param file
   * @param statistical summary
   */
  private void loadStats(String resource, Object u) throws Exception {
     
      DescriptiveStatistics d = null;
      SummaryStatistics s = null;
      if (u instanceof DescriptiveStatistics) {
          d = (DescriptiveStatistics) u;
      } else {
          s = (SummaryStatistics) u;
      }
     
      u.getClass().getDeclaredMethod("clear", null).invoke(u, null);
      mean = Double.NaN;
      std = Double.NaN;
     
      BufferedReader in =
          new BufferedReader(
                  new InputStreamReader(
                          getClass().getResourceAsStream(resource)));
     
      String line = null;
     
      for (int j = 0; j < 60; j++) {
          line = in.readLine();
          if (j == 40) {
              mean =
                  Double.parseDouble(
                          line.substring(line.lastIndexOf(":") + 1).trim());
          }
          if (j == 41) {
              std =
                  Double.parseDouble(
                          line.substring(line.lastIndexOf(":") + 1).trim());
          }
      }
     
      line = in.readLine();
     
      while (line != null) {
          if (d != null) {
              d.addValue(Double.parseDouble(line.trim()));
          else {
              s.addValue(Double.parseDouble(line.trim()));
          }
          line = in.readLine();
      }
View Full Code Here

                mk = createMicroKernel(microKernel);
                repository = createRepository(mk);

                // Run the test
                DescriptiveStatistics statistics = runTest(test, repository);
                if (statistics.getN() > 0) {
                    writeReport(test.toString(), name, microKernel, statistics);
                }
            } catch (RepositoryException re) {
                re.printStackTrace();
            } catch (Exception e) {
View Full Code Here

        }
    }

    private DescriptiveStatistics runTest(AbstractTest test,
            Repository repository) throws Exception {
        DescriptiveStatistics statistics = new DescriptiveStatistics();

        test.setUp(repository, credentials);
        try {
            // Run a few iterations to warm up the system
            if (warmup > 0) {
                long warmupEnd = System.currentTimeMillis() + warmup;
                while (System.currentTimeMillis() < warmupEnd) {
                    test.execute();
                }
            }

            // Run test iterations, and capture the execution times
            long runtimeEnd = System.currentTimeMillis() + runtime;
            while (System.currentTimeMillis() < runtimeEnd) {
                statistics.addValue(test.execute());
            }
        } finally {
            test.tearDown();
        }
View Full Code Here

      resultsWithReplica.add(new PerfEvalCallable(util.getHBaseAdmin(), replicaReadOpts).call());
      // TODO: sleep to let cluster stabilize, though monkey continues. is it necessary?
      Thread.sleep(5000l);
    }

    DescriptiveStatistics withoutReplicaStats = new DescriptiveStatistics();
    for (TimingResult tr : resultsWithoutReplica) {
      withoutReplicaStats.addValue(tr.elapsedTime);
    }
    DescriptiveStatistics withReplicaStats = new DescriptiveStatistics();
    for (TimingResult tr : resultsWithReplica) {
      withReplicaStats.addValue(tr.elapsedTime);
    }

    LOG.info(Objects.toStringHelper("testName")
      .add("withoutReplicas", resultsWithoutReplica)
      .add("withReplicas", resultsWithReplica)
      .add("withoutReplicasMean", withoutReplicaStats.getMean())
      .add("withReplicasMean", withReplicaStats.getMean())
      .toString());

    assertTrue(
      "Running with region replicas under chaos should be as fast or faster than without. "
      + "withReplicas.mean: " + withReplicaStats.getMean() + "ms "
      + "withoutReplicas.mean: " + withoutReplicaStats.getMean() + "ms.",
      withReplicaStats.getMean() <= withoutReplicaStats.getMean());
  }
View Full Code Here

  }

  public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
    Map<String, DescriptiveStatistics> results = new HashMap<String, DescriptiveStatistics>();
    for (RegionEnvironment env : coprocessors) {
      DescriptiveStatistics ds = new DescriptiveStatistics();
      if (env.getInstance() instanceof RegionObserver) {
        for (Long time : env.getExecutionLatenciesNanos()) {
          ds.addValue(time);
        }
        // Ensures that web ui circumvents the display of NaN values when there are zero samples.
        if (ds.getN() == 0) {
          ds.addValue(0);
        }
        results.put(env.getInstance().getClass().getSimpleName(), ds);
      }
    }
    return results;
View Full Code Here

        MetricsRegionSource.NUM_FILES_COMPACTED_DESC),
        this.regionWrapper.getNumFilesCompacted());
    for (Map.Entry<String, DescriptiveStatistics> entry : this.regionWrapper
        .getCoprocessorExecutionStatistics()
        .entrySet()) {
      DescriptiveStatistics ds = entry.getValue();
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Min: "), ds.getMin() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Mean: "), ds.getMean() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Max: "), ds.getMax() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "90th percentile: "), ds
          .getPercentile(90d) / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "95th percentile: "), ds
          .getPercentile(95d) / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "99th percentile: "), ds
          .getPercentile(99d) / 1000);
    }

  }
View Full Code Here

  }

  public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
    Map<String, DescriptiveStatistics> results = new HashMap<String, DescriptiveStatistics>();
    for (RegionEnvironment env : coprocessors) {
      DescriptiveStatistics ds = new DescriptiveStatistics();
      if (env.getInstance() instanceof RegionObserver) {
        for (Long time : env.getExecutionLatenciesNanos()) {
          ds.addValue(time);
        }
        // Ensures that web ui circumvents the display of NaN values when there are zero samples.
        if (ds.getN() == 0) {
          ds.addValue(0);
        }
        results.put(env.getInstance().getClass().getSimpleName(), ds);
      }
    }
    return results;
View Full Code Here

        MetricsRegionSource.NUM_FILES_COMPACTED_DESC),
        this.regionWrapper.getNumFilesCompacted());
    for (Map.Entry<String, DescriptiveStatistics> entry : this.regionWrapper
        .getCoprocessorExecutionStatistics()
        .entrySet()) {
      DescriptiveStatistics ds = entry.getValue();
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Min: "), ds.getMin() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Mean: "), ds.getMean() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "Max: "), ds.getMax() / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "90th percentile: "), ds
          .getPercentile(90d) / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "95th percentile: "), ds
          .getPercentile(95d) / 1000);
      mrb.addGauge(Interns.info(regionNamePrefix + " " + entry.getKey() + " "
          + MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS,
        MetricsRegionSource.COPROCESSOR_EXECUTION_STATISTICS_DESC + "99th percentile: "), ds
          .getPercentile(99d) / 1000);
    }

  }
View Full Code Here

            //Initialization of outer statistic agregators
            DescriptiveStatistics[] statsMean = new DescriptiveStatistics[maxThread];
            DescriptiveStatistics[] statsSTD = new DescriptiveStatistics[maxThread];
            for (int threads = 1; threads <= maxThread; ++threads) {
                statsMean[threads - 1] = new DescriptiveStatistics();
                statsSTD[threads - 1] = new DescriptiveStatistics();
            }

            for (; trys-- > 0;) { //Each try == one random sum
                DescriptiveStatistics[] stats = new DescriptiveStatistics[maxThread];
                Sum[] sums = random2Sums();
                System.out.println("try " + trys);
                for (int threads = 1; threads <= maxThread; ++threads) {
                    DescriptiveStatistics ds = new DescriptiveStatistics();

                    for (int i = 0; i < 10; ++i) { //Each random sum repeatedly tested 1000 times
                        Sum[] sums_ = new Sum[]{sums[0].clone(), sums[1].clone()};
                        long start = System.nanoTime();
                        PairEC pec = new PairEC(sums_[0], sums_[1], NaiveSumCollectIP.FACTORY, ScalarsSplitter.INSTANCE, threads);
                        Sum res = (Sum) pec.result();
//                        System.out.println(res.size() + " " + res);
                        ds.addValue(System.nanoTime() - start);
                    }

                    stats[threads - 1] = ds; //Saving statistics for one thread
                }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.stat.descriptive.DescriptiveStatistics

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.