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

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

Introduction

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

Prototype

public SummaryStatistics() 

Source Link

Document

Construct a SummaryStatistics instance

Usage

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 o  m*/

        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;
    }
}

From source file:org.trommel.trommel.functions.VariabilityReducer.java

/**
 * @param logger The {@link org.apache.log4j.Logger} instance that will be used by the RequiredReducer
 * @param fieldType Specifies if VariabilityReducer is processing numeric or categorical data.
 * /*from ww w. ja  v a2 s  .  co m*/
 * @throws IllegalArgumentException Where logger is null.
 */
public VariabilityReducer(Logger logger, FieldType fieldType) throws IllegalArgumentException {
    super(logger);

    this.fieldType = fieldType;

    if (this.fieldType == FieldType.numeric) {
        stats = new SummaryStatistics();
    } else {
        discoveredValues = new HashMap<String, Integer>();
    }
}

From source file:org.xronos.orcc.analysis.SimParser.java

public void createMaps() {

    for (Actor actor : network.getAllActors()) {
        Map<Action, SummaryStatistics> aTimeGoDone = new HashMap<Action, SummaryStatistics>();
        for (Action action : actor.getActions()) {
            OrccLogger.noticeln("Parsing weight: " + actor.getSimpleName() + "_" + action.getName());
            SummaryStatistics tGoDone = new SummaryStatistics();

            File actionFile = new File(
                    path + File.separator + actor.getSimpleName() + "_" + action.getName() + ".txt");
            try {
                FileInputStream iStream = new FileInputStream(actionFile);
                BufferedReader iBuffer = new BufferedReader(new InputStreamReader(iStream));
                String str;// w  w w .java 2s .  co  m
                int startTime = 0;
                Boolean fromOneZero = false;
                while ((str = iBuffer.readLine()) != null) {

                    int fIdx = str.indexOf(';', 0);
                    String stringTime = str.substring(0, fIdx);
                    int sIdx = str.indexOf(';', fIdx + 1);
                    String stringGo = str.substring(fIdx + 1, sIdx);
                    int tIdx = str.indexOf(';', sIdx + 1);
                    String stringDone = str.substring(sIdx + 1, tIdx);

                    int intTime = Integer.decode(stringTime);
                    int intGo = Integer.decode(stringGo);
                    int intDone = Integer.decode(stringDone);

                    if (intGo == 1 && intDone == 0) {
                        startTime = intTime;
                        fromOneZero = true;
                    } else if (intGo == 1 && intDone == 1) {
                        if (fromOneZero) {
                            tGoDone.addValue((intTime - startTime) / 100);
                            startTime = intTime;
                        } else {
                            tGoDone.addValue(0);
                        }
                    } else if (intGo == 0 && intDone == 1) {
                        fromOneZero = false;
                        tGoDone.addValue((intTime - startTime) / 100);
                    }

                }
                iBuffer.close();
                aTimeGoDone.put(action, tGoDone);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        statistics.put(actor, aTimeGoDone);
    }
}

From source file:playground.acmarmol.matsim2030.microcensus2010.MZPopulationUtils.java

public static void analyzeActivityTypesAndLengths(Population population) throws ExecutionException {
    LoadingCache<String, SummaryStatistics> activityDuration = CacheBuilder.newBuilder()
            .build(CacheLoader.from(new Supplier<SummaryStatistics>() {
                @Override//from www. j a v a  2 s  .c om
                public SummaryStatistics get() {
                    return new SummaryStatistics();
                }
            }));

    for (Person p : population.getPersons().values()) {
        if (p.getPlans().size() == 0)
            continue;

        Plan plan = p.getPlans().get(0);

        List<PlanElement> planElements = plan.getPlanElements();
        for (PlanElement pe : planElements) {
            if (!(pe instanceof Activity))
                continue;
            Activity activity = (Activity) pe;

            double startTime = activity.getStartTime();
            double endTime = activity.getEndTime();

            SummaryStatistics typeStats = activityDuration.get(activity.getType());
            if (endTime != Time.UNDEFINED_TIME) {
                if (startTime == Time.UNDEFINED_TIME)
                    startTime = 0;
                typeStats.addValue(endTime - startTime);
            }
        }
    }

    ConcurrentMap<String, SummaryStatistics> activityDurationMap = activityDuration.asMap();
    {
        int i = 0;
        final StringBuffer s = new StringBuffer();
        for (final String actType : activityDurationMap.keySet()) {
            final SummaryStatistics stats = activityDurationMap.get(actType);

            s.append(String.format("<param name=\"activityType_%d\" value=\"%s\" />\n", i, actType));
            s.append(String.format("<param name=\"activityPriority_%d\" value=\"1\" />\n", i));
            s.append(String.format("<param name=\"activityTypicalDuration_%d\" value=\"%s\" />\n", i,
                    Time.writeTime(stats.getMean())));
            s.append("\n");
            i++;
        }
        log.info("All activities:\n" + s.toString());
    }
}

From source file:prm4j.indexing.monitor.ParametricMonitorLogger.java

public ParametricMonitorLogger(BindingStore bindingStore, NodeManager nodeManager) {
    super();/*from  w  ww  .j  a v a 2 s .  c  o  m*/
    this.bindingStore = bindingStore;
    this.nodeManager = nodeManager;
    memStats = new SummaryStatistics();
    logMemoryConsumption();
}

From source file:ptrman.meter.func.BasicStatistics.java

public void setWindowSize(int w) {
    if (w == 0)/*  www  .  j a v  a 2  s. co m*/
        stat = new SummaryStatistics();
    else
        stat = new DescriptiveStatistics(w);
}

From source file:qea.MemoryLogger.java

MemoryLogger() {
    if (STATS_LOGGING) {
        memStats = new SummaryStatistics();
        String outputPath = "logs/qea-stats.log";
        System.out.println("Logging activated. Output path: " + outputPath);
        experimentName = getMandatorySystemProperty("prm4jeval.invocation") + " "
                + getMandatorySystemProperty("prm4jeval.benchmark") + " "
                + getMandatorySystemProperty("prm4jeval.paramProperty");
        logger = getFileLogger(outputPath);
    } else {//ww w . j a  va2 s.co m
        System.out.println("Memory logging not activated.");
    }
}

From source file:se.sics.kompics.network.data.Statistics.java

void endWindow() {
    updated = false;/*from w  w  w . j  a  va  2 s  .  c o m*/

    if (lastPrintTS > 0) {
        long diffL = System.nanoTime() - lastPrintTS;
        double diffD = ((double) diffL) / NANOSEC;
        double accumD = ((double) sizeAccum) / KILOBYTE;
        double tp = accumD / diffD;
        approxThroughput.addValue(tp);
    }
    sizeAccum = 0;
    lastWindowsRatio = selectionRatio;
    selectionRatio = new SummaryStatistics();
    lastPrintTS = System.nanoTime();
}

From source file:tech.tablesaw.columns.numbers.Stats.java

public static Stats create(final NumericColumn<?> values) {
    SummaryStatistics summaryStatistics = new SummaryStatistics();
    for (int i = 0; i < values.size(); i++) {
        summaryStatistics.addValue(values.getDouble(i));
    }/*from  www  .j a va 2s . c  o  m*/
    return getStats(values, summaryStatistics);
}

From source file:tools.descartes.bungee.evaluation.ScalabilityReproducibilityEvaluation.java

private SummaryStatistics createSummaryStatistics(List<Double> firstStepResults) {
    SummaryStatistics summaryStats = new SummaryStatistics();
    for (double x : firstStepResults) {
        summaryStats.addValue(x);//from  w ww  .  j  a v  a  2 s  . c  o  m
    }
    return summaryStats;
}