List of usage examples for org.apache.commons.math3.stat.descriptive SummaryStatistics getStandardDeviation
public double getStandardDeviation()
From source file:net.recommenders.rival.evaluation.statistics.StandardError.java
/** * Implements equation (8.13) from "Elementary Statistics: A Problem Solving * Approach 4th Edition", Andrew L. Comrey, Howard B. Lee * * @return the standard error as the ratio of the standard deviation divided * by the sqrt(number of users) of the distribution of difference scores. */// ww w . j a va 2 s. c o m public double getStandardError() { Set<V> overlap = new HashSet<V>(baselineMetricPerDimension.keySet()); overlap.retainAll(testMetricPerDimension.keySet()); // paired or matched samples --> analyse distribution of difference scores SummaryStatistics differences = new SummaryStatistics(); for (V key : overlap) { double diff = baselineMetricPerDimension.get(key) - testMetricPerDimension.get(key); differences.addValue(diff); } double e = differences.getStandardDeviation() / Math.sqrt(differences.getN()); return e; }
From source file:io.fabric8.example.stddev.http.StdDevProcessorTest.java
@Test public void testProcess() throws Exception { RandomGenerator rg = new JDKRandomGenerator(); double[] array = new double[10]; ObjectMapper objectMapper = new ObjectMapper(); for (int i = 0; i < array.length; i++) { array[i] = rg.nextDouble();/*www . j a va2 s . c o m*/ } String body = objectMapper.writeValueAsString(array); SummaryStatistics summaryStatistics = new SummaryStatistics(); List<Double> list = new ObjectMapper().readValue(body, List.class); for (Double value : list) { summaryStatistics.addValue(value); } String stdDev = Double.toString(summaryStatistics.getStandardDeviation()); resultEndpoint.expectedBodiesReceived(stdDev); template.sendBody(body); resultEndpoint.assertIsSatisfied(); }
From source file:io.fabric8.example.stddev.msg.StdDevProcessor.java
@Override public void process(Exchange exchange) throws Exception { System.err.println("STD DEV GOT EXCHANGE " + exchange); String message = exchange.getIn().getBody(String.class); ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); List<Double> values = objectMapper.readValue(message, typeFactory.constructCollectionType(List.class, Double.class)); SummaryStatistics summaryStatistics = new SummaryStatistics(); List<Double> list = new ObjectMapper().readValue(message, List.class); for (Double value : list) { summaryStatistics.addValue(value); }/*from w w w . ja v a2 s .c om*/ String stdDev = Double.toString(summaryStatistics.getStandardDeviation()); ActiveMQDestination replyTo = exchange.getIn().getHeader("JMSReplyTo", ActiveMQDestination.class); final String messageId = exchange.getIn().getHeader("JMSMessageID", String.class); if (replyTo != null) { Exchange copy = new DefaultExchange(exchange); copy.setPattern(ExchangePattern.InOnly); copy.getIn().setHeader(Variables.CORRELATION_HEADER, messageId); copy.getIn().setBody(stdDev); producerTemplate.send("jms:queue:" + replyTo.getPhysicalName(), copy); } }
From source file:cl.usach.managedbeans.CreditosManagedBean.java
public double buscarDesviacionStandarSrpintGrupo(SprintGrupos sprintG) { List<Equipo> eqs = buscarEquipos(sprintG); SummaryStatistics stats = new SummaryStatistics(); int s;/* w ww . ja va 2 s. c o m*/ for (Equipo equipo : eqs) { s = buscarTiempoTareas(equipo); stats.addValue(s); } double dv = stats.getStandardDeviation(); dv = (double) Math.round(dv * 10) / 10; return dv; }
From source file:gdsc.utils.HSB_Picker.java
private String summary(SummaryStatistics stats) { return String.format("%.3f +/- %.4f", stats.getMean(), stats.getStandardDeviation()); }
From source file:net.recommenders.rival.evaluation.statistics.ConfidenceInterval.java
/** * Method that takes only one metric as parameter. It is useful when * comparing more than two metrics (so that a confidence interval is * computed for each of them), as suggested in [Sakai, 2014] * * @param alpha probability of incorrectly rejecting the null hypothesis (1 * - confidence_level)/*from ww w .j av a2s . com*/ * @param metricValuesPerDimension one value of the metric for each * dimension * @return array with the confidence interval: [mean - margin of error, mean * + margin of error] */ public double[] getConfidenceInterval(final double alpha, final Map<?, Double> metricValuesPerDimension) { SummaryStatistics differences = new SummaryStatistics(); for (Double d : metricValuesPerDimension.values()) { differences.addValue(d); } return getConfidenceInterval(alpha, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean()); }
From source file:net.sourceforge.jabm.report.AbstractReportVariables.java
public void recordSummaryStatistics(Object statName, Map<Object, Number> variables, SummaryStatistics stats) { variables.put(createVariable(statName + ".mean"), stats.getMean()); variables.put(createVariable(statName + ".min"), stats.getMin()); variables.put(createVariable(statName + ".max"), stats.getMax()); variables.put(createVariable(statName + ".n"), stats.getN()); variables.put(createVariable(statName + ".stdev"), stats.getStandardDeviation()); }
From source file:cl.usach.managedbeans.CreditosManagedBean.java
public double buscarDesviacionEstandarSprintAsignatura(SprintAsignatura sprintA) { List<SprintGrupos> spgs = buscarSprintGrupos(sprintA); SummaryStatistics stats = new SummaryStatistics(); int a;/*from w w w . j a v a 2s . c o m*/ for (SprintGrupos sprintGrupos : spgs) { List<Equipo> eqs = buscarEquipos(sprintGrupos); for (Equipo equipo : eqs) { a = buscarTiempoTareas(equipo); stats.addValue(a); } } double dv = stats.getStandardDeviation(); dv = (double) Math.round(dv * 10) / 10; return dv; }
From source file:fr.gael.drb.cortex.topic.sentinel3.jai.operator.QuicklookSlstrRIF.java
private BufferedImage toGrayScale(Raster in, PixelCorrection c, boolean invertColors, boolean ignoreBadStats) { int width = in.getWidth(); int height = in.getHeight(); // compute stats SummaryStatistics stats = new SummaryStatistics(); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { int pixel = checkAndApplyCorrection(in.getSample(i, j, 0), c); if (pixel != c.nodata) stats.addValue(pixel);//from w w w .j a va 2 s. com } } double lowerBound = Math.max(stats.getMin(), stats.getMean() - 3 * stats.getStandardDeviation()); double upperBound = Math.min(stats.getMax(), stats.getMean() + 3 * stats.getStandardDeviation()); if (!ignoreBadStats) if (Double.isNaN(stats.getMean()) || Double.isNaN(stats.getStandardDeviation()) || stats.getStandardDeviation() < 1) throw new IllegalStateException("Ugly band stats. Acquired during night?"); return toGrayScale(in, c, invertColors, lowerBound, upperBound); }
From source file:net.recommenders.rival.evaluation.statistics.ConfidenceInterval.java
/** * Method that takes two metrics as parameters. It will compute the * differences between both (only considering the keys in the overlap) * * @param <V> type of keys for metrics * @param alpha probability of incorrectly rejecting the null hypothesis (1 * - confidence_level)//from w ww .j a v a 2 s . c om * @param baselineMetricPerDimension baseline metric, one value for each * dimension * @param testMetricPerDimension test metric, one value for each dimension * @param pairedSamples flag to indicate if the comparison should be made * for the distribution of difference scores (when true) or for the * distribution of differences between means * @return array with the confidence interval: [mean - margin of error, mean * + margin of error] */ public <V> double[] getConfidenceInterval(final double alpha, final Map<V, Double> baselineMetricPerDimension, final Map<V, Double> testMetricPerDimension, final boolean pairedSamples) { if (pairedSamples) { Set<V> overlap = new HashSet<V>(baselineMetricPerDimension.keySet()); overlap.retainAll(testMetricPerDimension.keySet()); // paired or matched samples --> analyse distribution of difference scores SummaryStatistics differences = new SummaryStatistics(); for (V key : overlap) { double diff = Math.abs(testMetricPerDimension.get(key) - baselineMetricPerDimension.get(key)); differences.addValue(diff); } return getConfidenceInterval(alpha / 2, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean()); } else { // independent samples --> analyse distribution of differences between means SummaryStatistics statsBaseline = new SummaryStatistics(); for (double d : baselineMetricPerDimension.values()) { statsBaseline.addValue(d); } SummaryStatistics statsTest = new SummaryStatistics(); for (double d : testMetricPerDimension.values()) { statsTest.addValue(d); } long dfT = statsBaseline.getN() + statsTest.getN() - 2; double sDif = Math.sqrt((1.0 / statsBaseline.getN() + 1.0 / statsTest.getN()) * (statsBaseline.getVariance() * (statsBaseline.getN() - 1) + statsTest.getVariance() * (statsTest.getN() - 1))); double mDif = Math.abs(statsTest.getMean() - statsBaseline.getMean()); return getConfidenceInterval(alpha, (int) dfT, (int) dfT, sDif, mDif); } }