Example usage for org.apache.commons.math.stat StatUtils geometricMean

List of usage examples for org.apache.commons.math.stat StatUtils geometricMean

Introduction

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

Prototype

public static double geometricMean(final double[] values) 

Source Link

Document

Returns the geometric mean of the entries in the input array, or Double.NaN if the array is empty.

Usage

From source file:playground.johannes.socialnetworks.snowball2.sim.deprecated.Estimator2.java

@Override
public void update(SampledGraph graph) {
    stats = new SampleStats(graph);

    TIntObjectHashMap<TIntArrayList> tmp = new TIntObjectHashMap<TIntArrayList>();

    for (Vertex vertex : graph.getVertices()) {
        if (((SampledVertex) vertex).isSampled()) {
            int k = vertex.getNeighbours().size();
            TIntArrayList values = tmp.get(k);
            if (values == null) {
                values = new TIntArrayList();
                tmp.put(k, values);//from www  .  jav a  2 s .  c o m
            }
            for (Vertex neighbor : vertex.getNeighbours()) {
                if (((SampledVertex) neighbor).isSampled()) {
                    values.add(neighbor.getNeighbours().size());
                }
            }
        }
    }

    kMap = new TIntDoubleHashMap();
    TIntObjectIterator<TIntArrayList> it = tmp.iterator();
    for (int i = 0; i < tmp.size(); i++) {
        it.advance();
        TIntArrayList list = it.value();
        double[] dList = new double[list.size()];
        for (int k = 0; k < list.size(); k++)
            dList[k] = list.get(k);
        kMap.put(it.key(), StatUtils.geometricMean(dList));
    }
}