List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics
public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException
From source file:com.loadtesting.core.data.TimeSerieData.java
public TimeSerieData(String name, List<TimeSample> samples, CapturerConfig config) { this.name = name; this.unit = config.getUnit(); this.volume = samples.size(); if (volume > 0) { TimeSample first = samples.get(0); this.unit = first.getTimeUnit(); this.opening = first.getTime(unit); TimeSample last = samples.get(volume - 1); this.closing = last.getTime(unit); this.samples = config.getFilter().filter(samples); DescriptiveStatistics stats = new DescriptiveStatistics(volume); for (TimeSample timeSample : samples) { stats.addValue(timeSample.getTime(unit)); }/*from w ww . j a v a 2s .co m*/ this.high = stats.getMax(); this.low = stats.getMin(); this.median = (high + low) / 2; this.typical = (high + low + closing) / 3; this.weightedClose = (high + low + closing + closing) / 4; this.sma = stats.getMean(); this.variance = stats.getVariance(); this.sd = stats.getStandardDeviation(); this.sum = stats.getSum(); this.sumsq = stats.getSumsq(); this.skewness = stats.getSkewness(); this.kurtosis = stats.getKurtosis(); this.geometricMean = stats.getGeometricMean(); this.populationVariance = stats.getPopulationVariance(); } else { this.samples = samples; } }
From source file:com.vsthost.rnd.jdeoptim.diagnostics.Diagnostics.java
/** * Constructs a new diagnostics instance. * * @param logging Indicates if logging is enabled or not. * @param statistics Indicates if detailed statistics are to be computed or not. *///from w w w . ja v a 2 s . c o m public Diagnostics(final boolean logging, final boolean statistics) { // Define the log format: this.logFormat = "%02d [%.6f] %s"; // Are we logging? this.logging = logging; // Are we collecting statistics? this.statistics = statistics; // Set default observers: this.addObserver(new Listener() { @Override public void evolutionStarted() { // Mark the started datetime. timeStarted = System.currentTimeMillis(); } @Override public void iterationStarted(int iteration) { // Nothing to be done... } @Override public void iterationFinished(int iteration, Population population) { // Are we logging? If yes log it: if (logging) { System.err.println(String.format(logFormat, iteration, population.getBestScore(), Arrays.toString(population.getBestMember()))); } if (statistics) { // Calculate the statistics: DescriptiveStatistics stats = new DescriptiveStatistics(population.getScores()); // Add the log entry to the evolution book: entries.add( new Diagnostics.Entry(population.getBestScore(), population.getBestMember(), stats)); } else { // Add the log entry to the evolution book: entries.add(new Diagnostics.Entry(population.getBestScore(), population.getBestMember(), null)); } } @Override public void evolutionFinished(Population population) { // Mark the end datetime: timeFinished = System.currentTimeMillis(); // Set the best member: bestMember = population.getBestMember(); // Set the best score: bestScore = population.getBestScore(); } }); }
From source file:edu.wisc.ssec.mcidasv.data.hydra.Statistics.java
public Statistics(FlatField fltFld) throws VisADException { rngVals = fltFld.getValues(false);/* w w w. jav a 2s. c om*/ rngTupLen = rngVals.length; numPoints = fltFld.getDomainSet().getLength(); numGoodPoints = new int[rngTupLen]; values_x = new double[rngTupLen][]; for (int k = 0; k < rngTupLen; k++) { values_x[k] = removeMissing(rngVals[k]); numGoodPoints[k] = values_x[k].length; } descriptiveStats = new DescriptiveStatistics[rngTupLen]; for (int k = 0; k < rngTupLen; k++) { descriptiveStats[k] = new DescriptiveStatistics(values_x[k]); } MathType rangeType = ((FunctionType) fltFld.getType()).getRange(); if (rangeType instanceof RealTupleType) { RealType[] rttypes = ((TupleType) rangeType).getRealComponents(); if (rngTupLen > 1) { statType = new RealTupleType(rttypes); } else { statType = rttypes[0]; } } else if (rangeType instanceof RealType) { statType = rangeType; } else { throw new VisADException("fltFld must be RealTupleType or RealType"); } pCorrelation = new PearsonsCorrelation(); }
From source file:mimir.ControlChart.java
public void dataReset(double[] newData) { this.data = new DescriptiveStatistics(newData); this.statsReset(); return;//from ww w. j a v a 2 s .c o m }
From source file:algorithm.NQueens.java
/** * Calculates statistics for the current data in the fitness, similarity, and mutation rate * buffers. After the statistics have been calculated they are added to the appropriate * fitnessStats, similarityStats, and mutationStats class members. * //w ww . jav a 2s. c o m * @param units The units for generations such as thousands (1000) or millions. */ @SuppressWarnings("serial") public static void calcStatistics(int units) { /* Calculate fitness stats */ DescriptiveStatistics descStats = new DescriptiveStatistics(Doubles.toArray(fitnessBuffer)); fitnessStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); /* Calculate chromosome similarity stats */ descStats = new DescriptiveStatistics(Doubles.toArray(similarityBuffer)); similarityStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); /* Calculate mutation rate stats for variable mutation */ if (mutation == null) { descStats = new DescriptiveStatistics(Doubles.toArray(mutationBuffer)); mutationStats.put((int) Math.ceil(numGenerations / (double) units), descStats.getMean()); } /* Calculate the duplicate solutions statistics */ if (duplicateBuffer.size() > 0) { final DescriptiveStatistics descDupStats = new DescriptiveStatistics( Doubles.toArray(duplicateBuffer.values())); duplicateStats.put((int) Math.ceil(numGenerations / (double) units), new ArrayList<Double>() { { add((double) duplicateBuffer.size()); add(descDupStats.getMean()); } }); } else { duplicateStats.put((int) Math.ceil(numGenerations / (double) units), new ArrayList<Double>() { { add(0.0); add(0.0); } }); } /* Clear the buffers */ mutationBuffer.clear(); fitnessBuffer.clear(); similarityBuffer.clear(); duplicateBuffer.clear(); }
From source file:es.csic.iiia.planes.util.InverseWishartDistributionTest.java
private double testGaussian(double scale) { double[] means = new double[] { 0, 0 }; double[][] covariances = new double[][] { { scale, 0 }, { 0, scale } }; MultivariateNormalDistribution uniform = new MultivariateNormalDistribution(means, covariances); DescriptiveStatistics stats = new DescriptiveStatistics(NORMAL_SAMPLES); for (int i = 0; i < NORMAL_SAMPLES; i++) { double[] xy = uniform.sample(); final double x = xy[0]; final double y = xy[1]; stats.addValue(Math.sqrt(x * x + y * y)); }/*from w w w .j a v a 2s . co m*/ return stats.getPercentile(90); }
From source file:com.github.jessemull.microflexdouble.stat.NTest.java
/** * Tests the plate statistics method.//from w ww . j a v a 2s .c o m */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Integer> resultMap = new TreeMap<Well, Integer>(); Map<Well, Integer> returnedMap = n.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (double db : well) { input[index++] = db; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getN(); resultMap.put(well, (int) result); } for (Well well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:gobblin.util.limiter.stressTest.RateComputingLimiterContainer.java
private @Nullable DescriptiveStatistics getNormalizedStatistics(String key, Collection<? extends Number> values) { long now = System.currentTimeMillis(); long deltaTime = 0; if (this.lastReportTimes.containsKey(key)) { deltaTime = now - this.lastReportTimes.get(key); }//from w w w . j a v a2 s . c o m this.lastReportTimes.put(key, now); if (deltaTime == 0) { return null; } double[] normalizedValues = new double[values.size()]; int i = 0; for (Number value : values) { normalizedValues[i++] = 1000 * value.doubleValue() / deltaTime; } return new DescriptiveStatistics(normalizedValues); }
From source file:com.github.jessemull.microflexbigdecimal.stat.NTest.java
/** * Tests the plate statistics method./* www .ja v a 2 s .c o m*/ */ @Test public void testPlate() { for (Plate plate : array) { Map<Well, Integer> resultMap = new TreeMap<Well, Integer>(); Map<Well, Integer> returnedMap = n.plate(plate); for (Well well : plate) { double[] input = new double[well.size()]; int index = 0; for (BigDecimal bd : well) { input[index++] = bd.doubleValue(); } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getN(); resultMap.put(well, (int) result); } for (Well well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }
From source file:com.github.jessemull.microflex.stat.statdouble.NDoubleTest.java
/** * Tests the plate statistics method./* w w w . j a v a 2 s . c o m*/ */ @Test public void testPlate() { for (PlateDouble plate : array) { Map<WellDouble, Integer> resultMap = new TreeMap<WellDouble, Integer>(); Map<WellDouble, Integer> returnedMap = n.plate(plate); for (WellDouble well : plate) { double[] input = new double[well.size()]; int index = 0; for (double db : well) { input[index++] = db; } DescriptiveStatistics stat = new DescriptiveStatistics(input); double result = stat.getN(); resultMap.put(well, (int) result); } for (WellDouble well : plate) { int result = resultMap.get(well); int returned = returnedMap.get(well); assertEquals(result, returned); } } }