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

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

Introduction

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

Prototype

public void addValue(double v) 

Source Link

Document

Adds the value to the dataset.

Usage

From source file:gov.nih.nci.caintegrator.application.study.deployment.GenomicDataHelper.java

private float computeGeneReporterValue(Collection<AbstractReporter> probeSetReporters,
        ArrayDataValues probeSetValues, ArrayData arrayData, AbstractReporter geneReporter) {
    Sample sample = arrayData.getSample();
    DescriptiveStatistics statistics = new DescriptiveStatistics();
    for (AbstractReporter reporter : probeSetReporters) {
        statistics.addValue(probeSetValues.getFloatValue(arrayData, reporter, EXPRESSION_SIGNAL));
        if (reporter.getSamplesHighVariance().contains(sample)) {
            geneReporter.getSamplesHighVariance().add(sample);
            sample.getReportersHighVariance().add(geneReporter);
        }// w ww.ja  v a2 s  .  c  o m
    }
    return (float) statistics.getPercentile(FIFTIETH_PERCENTILE);
}

From source file:ijfx.core.stats.DefaultImageStatisticsService.java

public <T extends RealType<T>> DescriptiveStatistics getDescriptiveStatistics(
        RandomAccessibleInterval<T> interval) {

    DescriptiveStatistics stats = new DescriptiveStatistics();

    Cursor<T> cursor = Views.iterable(interval).cursor();

    cursor.reset();/*from  w  ww  .  j a  va2 s.  c  o  m*/
    while (cursor.hasNext()) {
        cursor.fwd();
        stats.addValue(cursor.get().getRealDouble());
    }

    return stats;

}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7bConvArgRankProducer.java

@SuppressWarnings("unchecked")
public static void prepareData(String[] args) throws Exception {
    String inputDir = args[0];/* w  w  w  .j ava 2s .com*/
    File outputDir = new File(args[1]);

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    List<File> files = IOHelper.listXmlFiles(new File(inputDir));

    // take only the gold data for this task
    String prefix = "all_DescendingScoreArgumentPairListSorter";
    Iterator<File> iterator = files.iterator();
    while (iterator.hasNext()) {
        File file = iterator.next();

        if (!file.getName().startsWith(prefix)) {
            iterator.remove();
        }
    }

    int totalArgumentsCounter = 0;

    DescriptiveStatistics statsPerTopic = new DescriptiveStatistics();

    for (File file : files) {
        List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream()
                .fromXML(file);

        String name = file.getName().replaceAll(prefix, "").replaceAll("\\.xml", "");

        PrintWriter pw = new PrintWriter(new File(outputDir, name + ".csv"), "utf-8");
        pw.println("#id\trank\targument");

        Graph graph = buildGraphFromPairs(argumentPairs);

        Map<String, Argument> arguments = collectArguments(argumentPairs);

        int argumentsPerTopicCounter = arguments.size();

        PageRank pageRank = new PageRank();
        pageRank.setVerbose(true);
        pageRank.init(graph);

        for (Node node : graph) {
            String id = node.getId();
            double rank = pageRank.getRank(node);

            System.out.println(id);

            Argument argument = arguments.get(id);

            String text = Step7aLearningDataProducer.multipleParagraphsToSingleLine(argument.getText());

            pw.printf(Locale.ENGLISH, "%s\t%.5f\t%s%n", argument.getId(), rank, text);
        }

        totalArgumentsCounter += argumentsPerTopicCounter;
        statsPerTopic.addValue(argumentsPerTopicCounter);

        pw.close();
    }

    System.out.println("Total gold arguments: " + totalArgumentsCounter);
    System.out.println(statsPerTopic);
}

From source file:com.insightml.evaluation.functions.AbstractIndependentLabelsObjectiveFunction.java

@Override
public final DescriptiveStatistics acrossLabels(
        final List<? extends Predictions<? extends E, ? extends T>>[] predictions) {
    final DescriptiveStatistics stats = new DescriptiveStatistics();
    for (final List<? extends Predictions<? extends E, ? extends T>> predz : predictions) {
        for (final Predictions<? extends E, ? extends T> preds : predz) {
            for (final double val : label(preds.getPredictions(), preds.getExpected(), preds.getWeights(),
                    preds.getSamples(), preds.getLabelIndex()).getValues()) {
                stats.addValue(val);
            }//from   w  w w  .  ja v a2  s .com
        }
    }
    return stats;
}

From source file:com.facebook.stats.cardinality.TestHyperLogLog.java

@Test(groups = "slow")
public void testError() throws Exception {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    int buckets = 2048;
    for (int i = 0; i < 10000; ++i) {
        HyperLogLog estimator = new HyperLogLog(buckets);
        Set<Long> randomSet = makeRandomSet(5 * buckets);
        for (Long value : randomSet) {
            estimator.add(value);/*  w  ww .  j a  va  2s.com*/
        }

        double error = (estimator.estimate() - randomSet.size()) * 1.0 / randomSet.size();
        stats.addValue(error);
    }

    assertTrue(stats.getMean() < 1e-2);
    assertTrue(stats.getStandardDeviation() < 1.04 / Math.sqrt(buckets));
}

From source file:ijfx.core.stats.DefaultImageStatisticsService.java

@Override
public DescriptiveStatistics getDatasetDescriptiveStatistics(Dataset dataset) {
    DescriptiveStatistics summary = new DescriptiveStatistics();
    Cursor<RealType<?>> cursor = dataset.cursor();
    cursor.reset();/*w w w.ja v a2s.c  om*/

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

    }
    return summary;
}

From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java

public double stdev() {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < this.values.size(); i++)
        stats.addValue(this.values.get(i));

    return stats.getStandardDeviation();
}

From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java

public double skewness() {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < this.values.size(); i++)
        stats.addValue(this.values.get(i));

    return stats.getSkewness();
}

From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java

public double unbiasedExcessKurtosis() {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < this.values.size(); i++)
        stats.addValue(this.values.get(i));

    return stats.getKurtosis();
}

From source file:info.financialecology.finance.utilities.datastruct.DoubleTimeSeries.java

public double mean() {
    DescriptiveStatistics stats = new DescriptiveStatistics();

    for (int i = 0; i < this.values.size(); i++)
        stats.addValue(this.values.get(i));

    return stats.getMean();
}