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

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

Introduction

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

Prototype

public long getN() 

Source Link

Document

Returns the number of available values

Usage

From source file:com.insightml.data.features.stats.FeatureStatistics.java

private int getDistinct(final String feature) {
    final DescriptiveStatistics stat = stats.get(feature);
    if (stat == null) {
        return 0;
    }//from w  w  w. j a  v a2  s  .  c  o m
    final Set<Double> values = Sets.create((int) stat.getN());
    for (final double val : stat.getValues()) {
        values.add(val);
    }
    return values.size();
}

From source file:io.hops.leaderElection.experiments.ExperimentDriver.java

public void writeMessageToFile(int numProcesses, DescriptiveStatistics failOverStats,
        DescriptiveStatistics tpStats) throws IOException {
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("summary.log", true)));
    out.println(numProcesses + " " + tpStats.getN() + " " + tpStats.getMin() + " " + tpStats.getMax() + " "
            + tpStats.getMean() + " " + tpStats.getStandardDeviation() + " "
            + (tpStats.getStandardDeviation() / Math.sqrt(tpStats.getN())) + " " + failOverStats.getN() + " "
            + failOverStats.getMin() + " " + failOverStats.getMax() + " " + failOverStats.getMean() + " "
            + failOverStats.getStandardDeviation() + " "
            + (failOverStats.getStandardDeviation() / Math.sqrt(failOverStats.getN())));
    out.close();/*from  w  w w.  j  a  v a  2s.  co  m*/
}

From source file:ijfx.core.overlay.PixelStatisticsBase.java

public PixelStatisticsBase(DescriptiveStatistics stats) {

    setMean(stats.getMean());//from  www .j av a 2  s.co  m
    setMax(stats.getMax());
    setStandardDeviation(stats.getStandardDeviation());
    setVariance(stats.getVariance());
    setMedian(stats.getPercentile(50));
    setPixelCount(stats.getN());
    setMin(stats.getMin());

}

From source file:mase.stat.FitnessStat.java

/**
 * Prints out the statistics, but does not end with a println -- this lets
 * overriding methods print additional statistics on the same line
 *///from ww  w. j  ava2 s .  co m
@Override
public void postEvaluationStatistics(final EvolutionState state) {
    super.postEvaluationStatistics(state);

    int subpops = state.population.subpops.length; // number of supopulations
    DescriptiveStatistics[] fitness = new DescriptiveStatistics[subpops];
    for (int i = 0; i < subpops; i++) {
        fitness[i] = new DescriptiveStatistics();
    }
    int evals = state.evaluator.p_problem instanceof MaseProblem
            ? ((MaseProblem) state.evaluator.p_problem).getTotalEvaluations()
            : 0;

    // gather per-subpopulation statistics
    for (int x = 0; x < subpops; x++) {
        for (int y = 0; y < state.population.subpops[x].individuals.length; y++) {
            if (state.population.subpops[x].individuals[y].evaluated) {// he's got a valid fitness
                // update fitness
                double f = ((ExpandedFitness) state.population.subpops[x].individuals[y].fitness)
                        .getFitnessScore();
                bestSoFar[x] = Math.max(bestSoFar[x], f);
                absoluteBest = Math.max(absoluteBest, f);
                fitness[x].addValue(f);
            }
        }
        // print out fitness information
        if (doSubpops) {
            state.output.println(state.generation + " " + evals + " " + x + " " + fitness[x].getN() + " "
                    + fitness[x].getMin() + " " + fitness[x].getMean() + " " + fitness[x].getMax() + " "
                    + bestSoFar[x], statisticslog);
        }
    }

    // Now gather global statistics
    DescriptiveStatistics global = new DescriptiveStatistics();
    for (DescriptiveStatistics ds : fitness) {
        for (double v : ds.getValues()) {
            global.addValue(v);
        }
    }

    state.output.println(state.generation + " " + evals + " NA " + global.getN() + " " + global.getMin() + " "
            + global.getMean() + " " + global.getMax() + " " + absoluteBest, statisticslog);
}

From source file:com.insightml.models.meta.VoteModel.java

private double resolve(final DescriptiveStatistics stats) {
    switch (strategy) {
    case AVERAGE:
        return stats.getMean();
    case MEDIAN:/* ww  w .  ja v a2  s  .c o  m*/
        return stats.getPercentile(50);
    case GEOMETRIC:
        return stats.getGeometricMean();
    case HARMONIC:
        double sum = 0;
        for (final double value : stats.getValues()) {
            sum += 1 / value;
        }
        return stats.getN() * 1.0 / sum;
    default:
        throw new IllegalStateException();
    }
}

From source file:com.github.jessemull.microflex.stat.statinteger.NIntegerTest.java

/**
 * Tests well calculation./*  w  w w.  ja va  2s .  c  o m*/
 */
@Test
public void testWell() {

    for (PlateInteger plate : array) {

        for (WellInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double db : well) {
                input[index++] = db;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexdouble.stat.NTest.java

/**
 * Tests well calculation.//  w w w .  j a v  a2 s.c  om
 */
@Test
public void testWell() {

    for (Plate plate : array) {

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double db : well) {
                input[index++] = db;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statdouble.NDoubleTest.java

/**
 * Tests well calculation.//from  w  w w  .j a  v  a  2s.c o  m
 */
@Test
public void testWell() {

    for (PlateDouble plate : array) {

        for (WellDouble well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double db : well) {
                input[index++] = db;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statbigdecimal.NBigDecimalTest.java

/**
 * Tests well calculation./*from w ww  . j  a  v  a 2 s. c o m*/
 */
@Test
public void testWell() {

    for (PlateBigDecimal plate : array) {

        for (WellBigDecimal well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigDecimal bd : well) {
                input[index++] = bd.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java

/**
 * Tests well calculation.//from w  ww.j  av  a2s  . co m
 */
@Test
public void testWell() {

    for (PlateBigInteger plate : array) {

        for (WellBigInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}