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: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   ww  w  .  j ava  2s.  c om*/

    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);/* w w  w.  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;//from  w ww .  j a  va  2  s  .  c o m
    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);/*www  .  j av a2  s.  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));
}