Example usage for org.apache.commons.math3.stat.descriptive SummaryStatistics addValue

List of usage examples for org.apache.commons.math3.stat.descriptive SummaryStatistics addValue

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive SummaryStatistics addValue.

Prototype

public void addValue(double value) 

Source Link

Document

Add a value to the data

Usage

From source file:edu.uiowa.icts.bluebutton.json.view.StatsFinder.java

private SummaryStatistics findStats() {
    SummaryStatistics stats = new SummaryStatistics();
    stats.setVarianceImpl(new Variance(false));
    for (IGetStats d : this.list) {
        if (d.getDoubleValue() != null) {
            stats.addValue(d.getDoubleValue());
        }//from  w  w  w.ja  va2  s  .c  o m
    }
    return stats;
}

From source file:net.sourceforge.jabm.report.SummaryStatisticsReportVariables.java

@Override
public void compute(SimEvent event) {
    super.compute(event);
    reportVariables.compute(event);//  ww w.j a  va 2s. c  om
    Map<Object, Number> bindings = reportVariables.getVariableBindings();
    for (Object variable : bindings.keySet()) {
        SummaryStatistics stats = summaryVariableBindings.get(variable);
        if (stats == null) {
            stats = new SummaryStatistics();
            summaryVariableBindings.put(variable, stats);
        }
        stats.addValue(bindings.get(variable).doubleValue());
    }
}

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  w ww.  j a  v a2  s .c  om*/
 * @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:ijfx.core.stats.DefaultIjfxStatisticService.java

@Override
public SummaryStatistics getDatasetStatistics(Dataset dataset) {
    SummaryStatistics summary = new SummaryStatistics();
    Cursor<RealType<?>> cursor = dataset.cursor();
    cursor.reset();/*from   w w w .  j av  a 2s.  c om*/

    while (cursor.hasNext()) {
        cursor.fwd();
        double value = cursor.get().getRealDouble();
        summary.addValue(value);

    }
    return summary;
}

From source file:model.scenario.SimpleBuyerScenarioTest.java

@Test
public void rightPriceAndQuantityTestWithCascadeControllerFixed4Buyers() {
    for (int i = 0; i < 20; i++) {
        //to sell 4 you need to price them between 60 and 51 everytime
        final MacroII macroII = new MacroII(System.currentTimeMillis());
        SimpleBuyerScenario scenario = new SimpleBuyerScenario(macroII);
        scenario.setControllerType(CascadePIDController.class);
        scenario.setTargetInventory(20);
        scenario.setConsumptionRate(4);/*from  ww w.  j  a  v a  2  s .c o m*/
        scenario.setNumberOfBuyers(4);
        scenario.setNumberOfSuppliers(50);
        scenario.setSupplyIntercept(0);
        scenario.setSupplySlope(1);

        //4 buyers, buying 4 each, should be 16 units in total

        macroII.setScenario(scenario);
        macroII.start();
        for (PurchasesDepartment department : scenario.getDepartments())
            department.setTradePriority(Priority.BEFORE_STANDARD);

        while (macroII.schedule.getTime() < 3500) {
            System.out.println("--------------------------------");
            macroII.schedule.step(macroII);

            for (PurchasesDepartment department : scenario.getDepartments())
                System.out.println("inflow: " + department.getTodayInflow() + ", price: "
                        + department.getLastOfferedPrice() + ", averaged: "
                        + department.getAveragedClosingPrice());

        }

        SummaryStatistics averagePrice = new SummaryStatistics();
        for (int j = 0; j < 1000; j++) {
            macroII.schedule.step(macroII);
            averagePrice.addValue(macroII.getMarket(UndifferentiatedGoodType.GENERIC).getLastPrice());
        }
        //price should be any between 60 and 51
        assertEquals(16, averagePrice.getMean(), .5d);
        assertEquals(macroII.getMarket(UndifferentiatedGoodType.GENERIC).getYesterdayVolume(), 16, 1d); //every day 4 goods should have been traded

    }

}

From source file:com.isentropy.accumulo.iterators.RowStatsTransformingIterator.java

@Override
protected void transformRange(SortedKeyValueIterator<Key, Value> input, KVBuffer output) throws IOException {
    SummaryStatistics stats = new SummaryStatistics();
    Key k = null;//  www . j  a  va  2  s .  c o  m
    while (input.hasTop()) {
        k = input.getTopKey();
        Value v = input.getTopValue();
        Object vo = value_input_serde.deserialize(v.get());
        if (vo instanceof Number) {
            stats.addValue(((Number) vo).doubleValue());
        }
        input.next();
    }
    output.append(k, new Value(value_output_serde.serialize(stats)));
}

From source file:net.sourceforge.jabm.report.BatchMetaReport.java

private void onSimulationFinished() {
    logger.debug("reports = " + reports);
    for (Report report : reports) {
        Map<Object, Number> singleSimulationVars = report.getVariableBindings();
        Iterator<Object> i = singleSimulationVars.keySet().iterator();
        while (i.hasNext()) {
            Object variable = i.next();
            Object value = singleSimulationVars.get(variable);
            if (value instanceof Number) {
                double dValue = singleSimulationVars.get(variable).doubleValue();
                SummaryStatistics stats = variables.get(variable);
                if (stats == null) {
                    stats = new SummaryStatistics();
                    variables.put(variable, stats);
                }//from   w  w  w. j  a  va  2s. c o m
                stats.addValue(dValue);
            }
        }
    }
}

From source file:net.sourceforge.jabm.report.PayoffMap.java

public void updatePayoff(Strategy strategy, double fitness) {
    SummaryStatistics stats = (SummaryStatistics) payoffs.get(strategy);
    if (stats == null) {
        stats = (SummaryStatistics) createStatisticalSummary(strategy);
        payoffs.put(strategy, stats);/*from  w w w  .  j  a v  a  2  s.  c om*/
        strategyIndex.add(strategy);
    }
    stats.addValue(fitness);
}

From source file:cl.usach.managedbeans.CreditosManagedBean.java

public double buscarPromedioSrpintGrupo(SprintGrupos springG) {
    List<Equipo> eqs = buscarEquipos(springG);
    SummaryStatistics stats = new SummaryStatistics();
    int s;/*from  w  ww  .  j  a va 2 s  .c  o m*/
    for (Equipo equipo : eqs) {
        s = buscarTiempoTareas(equipo);
        stats.addValue(s);
    }
    double mean = stats.getMean();
    mean = (double) Math.round(mean * 10) / 10;
    return mean;
}

From source file:cl.usach.managedbeans.CreditosManagedBean.java

public double buscarDesviacionStandarSrpintGrupo(SprintGrupos sprintG) {
    List<Equipo> eqs = buscarEquipos(sprintG);
    SummaryStatistics stats = new SummaryStatistics();
    int s;//from  w  w  w . j av a2  s.  c om
    for (Equipo equipo : eqs) {
        s = buscarTiempoTareas(equipo);
        stats.addValue(s);
    }
    double dv = stats.getStandardDeviation();
    dv = (double) Math.round(dv * 10) / 10;
    return dv;
}