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

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

Introduction

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

Prototype

public void addValue(double v) 

Source Link

Document

Adds the value to the dataset.

Usage

From source file:org.jgap.gp.function.statistics.StandardDeviation.java

@Override
public float execute_float(ProgramChromosome c, int n, Object[] args) {
    int size = size();
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < size; i++) {
        stats.addValue(c.execute_float(n, i, args));
    }//from  www .ja v a 2  s. c o  m
    return (float) stats.getStandardDeviation();
}

From source file:org.jgap.gp.function.statistics.Variance.java

@Override
public double execute_double(ProgramChromosome c, int n, Object[] args) {
    int size = size();
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < size; i++) {
        stats.addValue(c.execute_double(n, i, args));
    }// w w w .ja  v  a 2  s  .  c  om
    return stats.getVariance();
}

From source file:org.jgap.gp.function.statistics.Variance.java

@Override
public float execute_float(ProgramChromosome c, int n, Object[] args) {
    int size = size();
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < size; i++) {
        stats.addValue(c.execute_float(n, i, args));
    }/*from  w  ww  .  j  av  a  2  s  .c  o m*/
    return (float) stats.getVariance();
}

From source file:org.matsim.contrib.common.stats.Correlations.java

/**
 * /*from  w  w w  . j  a v a  2s.  com*/
 * @param valuesX
 *            a set of values.
 * @param valuesY
 *            a set of values.
 * @param discretizer
 *            a discretizer applied to the elements of <tt>valuesX</tt>.
 * @return a map where the keys are the elements of <tt>valuesX</tt> and
 *         where the values are descriptive statistics objects of a subset
 *         of <tt>valuesY</tt> the index of which is equal to elements of
 *         <tt>valuesX</tt> with equal value. The elements of
 *         <tt>valuesX</tt> are discretized with <tt>discretizer</tt>.
 */
public static TDoubleObjectHashMap<DescriptiveStatistics> statistics(double[] valuesX, double[] valuesY,
        Discretizer discretizer) {
    if (valuesX.length != valuesY.length)
        throw new IllegalArgumentException("Both arrays must not differ in size!");

    TDoubleObjectHashMap<DescriptiveStatistics> map = new TDoubleObjectHashMap<DescriptiveStatistics>();

    for (int i = 0; i < valuesX.length; i++) {
        double x = discretizer.discretize(valuesX[i]);
        DescriptiveStatistics stats = map.get(x);
        if (stats == null) {
            stats = new DescriptiveStatistics();
            map.put(x, stats);
        }
        stats.addValue(valuesY[i]);
    }

    return map;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.AbstractEdgeProperty.java

@Override
public DescriptiveStatistics statistics(Set<? extends Edge> edges) {
    DescriptiveStatistics stats = new DescriptiveStatistics();

    TObjectDoubleHashMap<Edge> values = values(edges);
    TObjectDoubleIterator<Edge> it = values.iterator();

    for (int i = 0; i < values.size(); i++) {
        it.advance();/*from w  w  w  .  j a va  2s .  c o m*/
        stats.addValue(it.value());
    }

    return stats;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.AbstractVertexProperty.java

@Override
public DescriptiveStatistics statistics(Set<? extends Vertex> vertices) {
    DescriptiveStatistics stats = new DescriptiveStatistics();

    TObjectDoubleHashMap<Vertex> values = values(vertices);
    TObjectDoubleIterator<Vertex> it = values.iterator();

    for (int i = 0; i < values.size(); i++) {
        it.advance();/* www  . j av  a  2 s. c om*/
        stats.addValue(it.value());
    }

    return stats;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.AnalyzerTask.java

protected DescriptiveStatistics singleValueStats(String key, double value,
        Map<String, DescriptiveStatistics> stats) {
    DescriptiveStatistics ds = new DescriptiveStatistics();
    ds.addValue(value);
    stats.put(key, ds);//from w  w  w.j a va 2s. c om
    return ds;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.Centrality.java

public DescriptiveStatistics closenessDistribution() {
    DescriptiveStatistics ds = new DescriptiveStatistics();

    if (sources == null) {
        for (double val : mCentrality.getVertexCloseness()) {
            if (!Double.isInfinite(val))
                ds.addValue(val);
        }//from   w  w  w . ja  v  a2s .c  om
    } else {
        for (Vertex v : sources) {
            int idx = y.getIndex(v);
            double val = mCentrality.getVertexCloseness()[idx];
            if (!Double.isInfinite(val))
                ds.addValue(val);
        }
    }
    return ds;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.Centrality.java

public DescriptiveStatistics vertexBetweennessDistribution() {
    DescriptiveStatistics distr = new DescriptiveStatistics();
    for (int i = 0; i < mCentrality.getVertexBetweenness().length; i++) {
        distr.addValue(mCentrality.getVertexBetweenness()[i]);
    }/* ww  w. j a  v a2  s .  co  m*/
    return distr;
}

From source file:org.matsim.contrib.socnetgen.sna.graph.analysis.Components.java

/**
 * Returns the distribution of the sizes of disconnected components.
 * /*from w  w w.j a v  a 2  s  .c om*/
 * @param graph
 *            a graph.
 * @return the distribution of the sizes of disconnected components.
 */
public DescriptiveStatistics distribution(Graph graph) {
    AdjacencyMatrix<Vertex> y = new AdjacencyMatrix<Vertex>(graph);
    List<TIntArrayList> components = extractComponents(y);
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (TIntArrayList component : components) {
        stats.addValue(component.size());
    }
    return stats;
}