List of usage examples for org.apache.commons.math3.stat.descriptive SummaryStatistics getStandardDeviation
public double getStandardDeviation()
From source file:org.cloudsimplus.testbeds.heuristics.DatacenterBrokerHeuristicRunner.java
@Override protected void printFinalResults(String metricName, SummaryStatistics stats) { System.out.printf("\n# %s for %d simulation runs\n", metricName, getNumberOfSimulationRuns()); if (!simulationRunsAndNumberOfBatchesAreCompatible()) { System.out.println(/*w ww.j a v a 2 s. c o m*/ "\tBatch means method was not be applied because the number of simulation runs is not greater than the number of batches."); } System.out.printf("\tRound-robin solution used by DatacenterBrokerSimple - Cost: %.2f\n", roundRobinSolution.getCost()); if (getNumberOfSimulationRuns() > 1) { System.out.printf("\tHeuristic solutions - Mean cost: %.2f Std. Dev.: %.2f\n", stats.getMean(), stats.getStandardDeviation()); showConfidenceInterval(stats); System.out.printf( "\n\tThe mean cost of heuristic solutions represent %.2f%% of the Round-robin mapping used by the DatacenterBrokerSimple\n", heuristicSolutionCostPercentageOfRoundRobinSolution(stats.getMean())); System.out.printf("Experiment execution mean time: %.2f seconds\n", runtimeStats.getMean()); } }
From source file:org.cloudsimplus.testbeds.linuxscheduler.CloudletSchedulerRunner.java
@Override protected void printFinalResults(String metricName, SummaryStatistics stats) { System.out.printf("Results for metric %s\n", metricName); System.out.printf(" Mean Number of Cloudlets: %.2f\n", cloudletsNumber.stream().mapToDouble(n -> n).average().orElse(0.0)); System.out.printf(" Cloudlet Completion Time Avg: %.2f | Std dev: %.2f\n", stats.getMean(), stats.getStandardDeviation()); System.out.printf(" Cloudlet Completion Min Avg Time: %.2f | Max avg time: %.2f\n", stats.getMin(), stats.getMax());//from w ww . ja va 2 s.c o m System.out.println(); }
From source file:org.hoidla.window.WindowUtils.java
/** * Identifies outliers/* w ww .j av a 2 s. co m*/ * @param data * @param outlierThresholdFactor * @param pattern * @return indexes outlying data points */ public static List<Integer> removeOutliers(double[] data, int outlierThresholdFactor, double[] pattern) { if (null != pattern && data.length != pattern.length) { throw new IllegalArgumentException("data and pattern need to be of same size"); } //stats SummaryStatistics stats = new SummaryStatistics(); for (double value : data) { stats.addValue(value); } double mean = stats.getMean(); double stdDev = stats.getStandardDeviation(); //thresholds double upThreshold = mean + outlierThresholdFactor * stdDev; double loThreshold = mean - outlierThresholdFactor * stdDev; //detect outliers List<Integer> outliers = new ArrayList<Integer>(); int i = 0; for (double value : data) { if (value > upThreshold || value < loThreshold) { //replace with pattern value so that there is no net effect if (null != pattern) { data[i] = pattern[i]; } outliers.add(i); } ++i; } return outliers; }
From source file:org.lightjason.agentspeak.action.buildin.math.statistic.EStatisticValue.java
/** * returns a statistic value/* ww w . ja v a 2 s .c om*/ * * @param p_statistic statistic object * @return statistic value */ public final double value(final SummaryStatistics p_statistic) { switch (this) { case GEOMETRICMEAN: return p_statistic.getGeometricMean(); case MAX: return p_statistic.getMax(); case MIN: return p_statistic.getMin(); case COUNT: return p_statistic.getN(); case POPULATIONVARIANCE: return p_statistic.getPopulationVariance(); case QUADRATICMEAN: return p_statistic.getQuadraticMean(); case SECONDMOMENT: return p_statistic.getSecondMoment(); case STANDARDDEVIATION: return p_statistic.getStandardDeviation(); case SUM: return p_statistic.getSum(); case SUMLOG: return p_statistic.getSumOfLogs(); case SUMSQUARE: return p_statistic.getSumsq(); case VARIANCE: return p_statistic.getVariance(); case MEAN: return p_statistic.getMean(); default: throw new CIllegalStateException( org.lightjason.agentspeak.common.CCommon.languagestring(this, "unknown", this)); } }
From source file:org.lightjason.agentspeak.action.builtin.math.statistic.EStatisticValue.java
/** * returns a statistic value//ww w .j a v a 2s .c o m * * @param p_statistic statistic object * @return statistic value */ public final double value(@Nonnull final SummaryStatistics p_statistic) { switch (this) { case GEOMETRICMEAN: return p_statistic.getGeometricMean(); case MAX: return p_statistic.getMax(); case MIN: return p_statistic.getMin(); case COUNT: return p_statistic.getN(); case POPULATIONVARIANCE: return p_statistic.getPopulationVariance(); case QUADRATICMEAN: return p_statistic.getQuadraticMean(); case SECONDMOMENT: return p_statistic.getSecondMoment(); case STANDARDDEVIATION: return p_statistic.getStandardDeviation(); case SUM: return p_statistic.getSum(); case SUMLOG: return p_statistic.getSumOfLogs(); case SUMSQUARE: return p_statistic.getSumsq(); case VARIANCE: return p_statistic.getVariance(); case MEAN: return p_statistic.getMean(); default: throw new CIllegalStateException( org.lightjason.agentspeak.common.CCommon.languagestring(this, "unknown", this)); } }
From source file:org.lpe.common.util.LpeNumericUtils.java
/** * Calculates confidence interval width for the given SummaryStatistics and * the significance level.//from w w w . jav a 2 s . c o m * * @param summaryStatistics * the data * @param significance * desired significance level * @return the width of the confidence interval around the mean with the * given significance level */ public static double getConfidenceIntervalWidth(SummaryStatistics summaryStatistics, double significance) { return getConfidenceIntervalWidth(summaryStatistics.getN(), summaryStatistics.getStandardDeviation(), significance); }
From source file:org.orbisgis.corejdbc.ReadTable.java
/** * Compute numeric stats of the specified table column using a limited input rows. Stats are not done in the sql side. * @param connection Available connection * @param tableName Table name/*from w w w . j a v a2 s. c o m*/ * @param columnName Column name * @param rowNum Row id * @param pm Progress monitor * @return An array of attributes {@link STATS} * @throws SQLException */ public static String[] computeStatsLocal(Connection connection, String tableName, String columnName, SortedSet<Integer> rowNum, ProgressMonitor pm) throws SQLException { String[] res = new String[STATS.values().length]; SummaryStatistics stats = new SummaryStatistics(); try (Statement st = connection.createStatement()) { // Cancel select PropertyChangeListener listener = EventHandler.create(PropertyChangeListener.class, st, "cancel"); pm.addPropertyChangeListener(ProgressMonitor.PROP_CANCEL, listener); try (ResultSet rs = st.executeQuery(String.format("SELECT %s FROM %s", columnName, tableName))) { ProgressMonitor fetchProgress = pm.startTask(rowNum.size()); while (rs.next() && !pm.isCancelled()) { if (rowNum.contains(rs.getRow())) { stats.addValue(rs.getDouble(columnName)); fetchProgress.endTask(); } } } finally { pm.removePropertyChangeListener(listener); } } res[STATS.SUM.ordinal()] = Double.toString(stats.getSum()); res[STATS.AVG.ordinal()] = Double.toString(stats.getMean()); res[STATS.COUNT.ordinal()] = Long.toString(stats.getN()); res[STATS.MIN.ordinal()] = Double.toString(stats.getMin()); res[STATS.MAX.ordinal()] = Double.toString(stats.getMax()); res[STATS.STDDEV_SAMP.ordinal()] = Double.toString(stats.getStandardDeviation()); return res; }
From source file:org.orekit.forces.gravity.SolidTidesFieldTest.java
@Test public void testInterpolationAccuracy() throws OrekitException { // The shortest periods are slightly below one half day for the tidal waves // considered here. This implies the sampling rate should be fast enough. // The tuning parameters we have finally settled correspond to a two hours // sample containing 12 points (i.e. one new point is computed every 10 minutes). // The observed relative interpolation error with these settings are essentially // due to Runge phenomenon at points sampling rate. Plotting the errors shows // singular peaks pointing out of merely numerical noise. final IERSConventions conventions = IERSConventions.IERS_2010; Frame itrf = FramesFactory.getITRF(conventions, true); TimeScale utc = TimeScalesFactory.getUTC(); UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true); NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5); SolidTidesField raw = new SolidTidesField(conventions.getLoveNumbers(), conventions.getTideFrequencyDependenceFunction(ut1), conventions.getPermanentTide(), conventions.getSolidPoleTide(ut1.getEOPHistory()), itrf, gravityField.getAe(), gravityField.getMu(), gravityField.getTideSystem(), CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon()); int step = 600; int nbPoints = 12; CachedNormalizedSphericalHarmonicsProvider interpolated = new CachedNormalizedSphericalHarmonicsProvider( raw, step, nbPoints, OrekitConfiguration.getCacheSlotsNumber(), 7 * Constants.JULIAN_DAY, 0.5 * Constants.JULIAN_DAY); // the following time range is located around the maximal observed error AbsoluteDate start = new AbsoluteDate(2003, 6, 12, utc); AbsoluteDate end = start.shiftedBy(3 * Constants.JULIAN_DAY); SummaryStatistics stat = new SummaryStatistics(); for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(60)) { NormalizedSphericalHarmonics rawHarmonics = raw.onDate(date); NormalizedSphericalHarmonics interpolatedHarmonics = interpolated.onDate(date); for (int n = 2; n < 5; ++n) { for (int m = 0; m <= n; ++m) { if (n < 4 || m < 3) { double cnmRaw = rawHarmonics.getNormalizedCnm(n, m); double cnmInterp = interpolatedHarmonics.getNormalizedCnm(n, m); double errorC = (cnmInterp - cnmRaw) / FastMath.abs(cnmRaw); stat.addValue(errorC); if (m > 0) { double snmRaw = rawHarmonics.getNormalizedSnm(n, m); double snmInterp = interpolatedHarmonics.getNormalizedSnm(n, m); double errorS = (snmInterp - snmRaw) / FastMath.abs(snmRaw); stat.addValue(errorS); }// w w w .j a v a2 s .c om } } } } Assert.assertEquals(0.0, stat.getMean(), 2.0e-12); Assert.assertTrue(stat.getStandardDeviation() < 2.0e-9); Assert.assertTrue(stat.getMin() > -9.0e-8); Assert.assertTrue(stat.getMax() < 8.0e-8); }
From source file:org.spotter.ext.detection.highmessaging.analyze.Analyzer.java
protected double standardDeviation(List<Double> values) { SummaryStatistics stats = new SummaryStatistics(); for (double val : values) { stats.addValue(val); }//from w ww.j av a 2 s. c om return stats.getStandardDeviation(); }
From source file:org.spotter.ext.detection.highmessaging.analyze.LinearAnalyzer.java
@Override public AnalyzeResult analyze() { // Values smoothed List<Double> valuesSmoothed = smooth(yValues, smoothingWide); // Values smoothed and normalized relative to the first List<Double> valuesSmoothedNormalized = normalize(valuesSmoothed, valuesSmoothed.get(0)); // Check if linear increasing List<Double> slopes = new ArrayList<Double>(); SummaryStatistics statsSlopesSmoothedNormalized = new SummaryStatistics(); for (int i = 0; i < xValues.size(); i++) { double slope = 1; if (i != 0) { slope = (valuesSmoothedNormalized.get(i) - valuesSmoothedNormalized.get(i - 1)) / (xValues.get(i) - xValues.get(i - 1)); }//from w w w.j a v a 2 s . c om statsSlopesSmoothedNormalized.addValue(slope); slopes.add(slope); // System.out.println((slope + "").replaceAll("\\.", ",")); } List<Double> slopesSmoothed = smooth(slopes, 2); int outlierCount = 0; double lowerBound = statsSlopesSmoothedNormalized.getMean() - statsSlopesSmoothedNormalized.getStandardDeviation(); lowerBound = 0.5; for (double val : slopesSmoothed) { // System.out.println((val + "").replaceAll("\\.", ",")); if (lowerBound > val) { outlierCount++; } } double pctOutlier = 1D / slopes.size() * outlierCount; // System.out.println(String.format("> Outlier: %d Pct Outlier: %.2f", outlierCount, pctOutlier)); if (pctOutlier > 1D - pctThreshold) { // Too much outside return AnalyzeResult.NEGATIVE; } else { // Alles ok return AnalyzeResult.POSITIVE; } }