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

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

Introduction

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

Prototype

public DescriptiveStatistics() 

Source Link

Document

Construct a DescriptiveStatistics instance with an infinite window

Usage

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  av a 2  s. c om
        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();/*w  w  w . j av  a 2  s.com*/
        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);/* w w w.jav a2s.  c  o  m*/
    stats.put(key, ds);
    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 ww.j a  v  a2s  .  c o  m
    } 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]);
    }/*from  ww  w .  j a  va  2  s . c  o  m*/
    return distr;
}

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

/**
 * Returns the distribution of the sizes of disconnected components.
 * /*w w w  .  ja va  2s.c o m*/
 * @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;
}

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

/**
 * Returns a descriptive statistics object containing the elements of <tt>vertices</tt>. The
 * graph is treated as undirected.//from  www. j av a 2 s  .c o  m
 * 
 * @param vertices
 *            a collection of vertices.
 *            
 * @return a descriptive statistics object.
 */
public DescriptiveStatistics statistics(Set<? extends Vertex> vertices) {
    DescriptiveStatistics distribution = new DescriptiveStatistics();
    for (Vertex v : vertices)
        distribution.addValue(v.getEdges().size());

    return distribution;
}

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

/**
 * Determines the degree distribution and the degree correlation of a graph.
 * Writes the histogram of the degree distribution into the output directory
 * (if specified).//from www .  j  ava  2  s .c om
 * 
 * @param graph
 *            a graph.
 * @param stats
 *            a map where the results of the analysis are stored.
 */
@Override
public void analyze(Graph graph, Map<String, DescriptiveStatistics> statsMap) {
    DescriptiveStatistics stats = module.statistics(graph.getVertices());
    printStats(stats, key);
    statsMap.put(key, stats);
    if (outputDirectoryNotNull()) {
        try {
            writeHistograms(stats, new LinearDiscretizer(1.0), key, false);
            writeHistograms(stats, new LinearDiscretizer(5.0), key + "_5", false);
            writeHistograms(stats, key, 13, 1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    stats = new DescriptiveStatistics();
    stats.addValue(module.assortativity(graph));
    statsMap.put("r_" + key, stats);
    printStats(stats, "r_" + key);
}

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

/**
 * Counts the number of vertices and edges in a graph.
 * /*from  ww w . j  a v  a2s  . c o m*/
 * @param graph
 *            a graph.
 * @param stats
 *            a map where the results of the analysis are stored.
 */
//   @Override
//   public void analyze(Graph graph, Map<String, Double> stats) {
////      int n_vertex = graph.getVertices().size();
////      int n_edge = graph.getEdges().size();
////      stats.put(NUM_VERTICES, new Double(n_vertex));
////      stats.put(NUM_EDGES, new Double(n_edge));
////      logger.info(String.format("%1$s = %2$s, %3$s = %4$s", NUM_VERTICES, n_vertex, NUM_EDGES, n_edge));
//   }

@Override
public void analyze(Graph graph, Map<String, DescriptiveStatistics> statsMap) {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    stats.addValue(graph.getVertices().size());
    statsMap.put(NUM_VERTICES, stats);
    printStats(stats, NUM_VERTICES);

    stats = new DescriptiveStatistics();
    stats.addValue(graph.getEdges().size());
    statsMap.put(NUM_EDGES, stats);
    printStats(stats, NUM_EDGES);
}

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

/**
 * Calculates the distribution of local clustering coefficients.
 * /*  www.ja v a 2  s . c  o m*/
 * @param vertices
 *            a set of vertices.
 * 
 * @return the distribution of local clustering coefficients.
 */
public DescriptiveStatistics localClusteringDistribution(Set<? extends Vertex> vertices) {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    TObjectDoubleHashMap<?> values = values(vertices);
    TObjectDoubleIterator<?> it = values.iterator();
    for (int i = 0; i < values.size(); i++) {
        it.advance();
        stats.addValue(it.value());
    }
    return stats;
}