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:tools.descartes.bungee.evaluation.ScalabilityReproducibilityEvaluation.java

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

From source file:uk.ac.diamond.scisoft.ncd.calibration.NCDAbsoluteCalibration.java

public void calibrate() {
    qMin = Math.max(absQ.min().doubleValue(), dataQ.min().doubleValue());
    qMax = Math.min(absQ.max().doubleValue(), dataQ.max().doubleValue());
    if (!(qMin < qMax)) {
        throw new IllegalArgumentException(
                "No calibration data found for the selected scattering vector range");
    }//from   www. ja  v a  2 s.co  m

    int dataQStart = Math.min(dataQ.getSize() - 1, DatasetUtils.findIndexGreaterThanOrEqualTo(dataQ, qMin));
    int dataQStop = Math.min(dataQ.getSize() - 1, DatasetUtils.findIndexGreaterThanOrEqualTo(dataQ, qMax));

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = dataQStart; i <= dataQStop; i++) {
        double qval = dataQ.getDouble(i);
        stats.addValue(absInterpolate.value(qval) / dataI.getDouble(i));
    }

    absScale = stats.getMean();
    absScaleStdDev = stats.getStandardDeviation();

    String msg = StringUtils.join(new String[] { "scale", Double.toString(absScale) }, " : ");
    System.out.println(msg);

    System.out.println("NCD Absolute Instensity Scaler");
    System.out.println(Double.toString(absScale));
    System.out.println("standard deviation:" + Double.toString(absScaleStdDev));

    calibratedData(dataI);
}

From source file:wsattacker.library.intelligentdos.success.TTestSuccessDecider.java

private double calculateProbability(Long[] run1, Long[] run2) {
    SummaryStatistics statisticsX = new SummaryStatistics();
    for (double value : run1) {
        statisticsX.addValue(value);
    }//from  w  ww .j a  v  a  2  s. co  m

    SummaryStatistics statisticsY = new SummaryStatistics();
    for (double value : run2) {
        statisticsY.addValue(value);
    }

    // two-sample
    double t = TestUtils.t(statisticsX, statisticsY);
    long degreesOfFreedom = statisticsX.getN() + statisticsY.getN() - 2;
    // p-value = 0.3002
    TDistribution tDistribution = new TDistribution(degreesOfFreedom);
    double pValue = tDistribution.cumulativeProbability(t);
    return pValue;
}

From source file:wsattacker.plugin.dos.dosExtension.mvc.model.AttackModel.java

private SummaryStatistics createNetworkStatistics() {
    int toSkip = 5;
    // generate Array from LogResults
    // loop all NetworkTestRequests and write to array
    int j = 0;//w ww  . j  a  v  a 2  s. c  om
    SummaryStatistics statistics = new SummaryStatistics();
    for (LogEntryRequest currentLogEntry : this.logListNetworktestRequests) {
        // skip first entries
        if (j >= toSkip) {
            statistics.addValue(currentLogEntry.getDuration());
            System.out.println("----add:" + (j - toSkip) + " - " + currentLogEntry.getDuration());
        }
        j++;
    }
    return statistics;
}

From source file:wsattacker.plugin.intelligentdos.StatisticTest.java

private static void statistics(double[] x, double[] y) {

    DecimalFormat df = new DecimalFormat("#.######");

    SummaryStatistics statisticsX = new SummaryStatistics();
    for (double value : x) {
        statisticsX.addValue(value);
    }//from  w  w  w  . j av a2s .  c  o m

    SummaryStatistics statisticsY = new SummaryStatistics();
    for (double value : y) {
        statisticsY.addValue(value);
    }

    // t = -0.5331
    double t = TestUtils.t(statisticsX, statisticsY);
    // df = 18
    long degreesOfFreedom = statisticsX.getN() + statisticsY.getN() - 2;
    // p-value = 0.3002
    TDistribution tDistribution = new TDistribution(degreesOfFreedom);
    double pValue = tDistribution.cumulativeProbability(t);

    // t = -0.5331, df = 18, p-value = 0.3002
    System.out.print("t = " + df.format(t));
    System.out.print(", df = " + degreesOfFreedom);
    System.out.println(", p-value = " + df.format(pValue));

    System.out.println("mean of x mean of y");
    System.out.println(df.format(statisticsX.getMean()) + " - " + df.format(statisticsY.getMean()));

    // Calculate 95% confidence interval
    double ci = calcMeanCI(statisticsY, 0.95);
    System.out.println(String.format("Confidence inteval 95%%: %f", ci));
}