Example usage for org.apache.commons.math.stat.ranking TiesStrategy AVERAGE

List of usage examples for org.apache.commons.math.stat.ranking TiesStrategy AVERAGE

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.ranking TiesStrategy AVERAGE.

Prototype

TiesStrategy AVERAGE

To view the source code for org.apache.commons.math.stat.ranking TiesStrategy AVERAGE.

Click Source Link

Document

Ties get the average of applicable ranks

Usage

From source file:geogebra.kernel.statistics.AlgoTiedRank.java

protected final void compute() {

    size = inputList.size();//w  w  w  .  java 2s. c  o m
    if (!inputList.isDefined() || size == 0) {
        outputList.setUndefined();
        return;
    }

    inputArray = new double[size];

    // load input value array from  geoList
    for (int i = 0; i < size; i++) {
        GeoElement geo = inputList.get(i);
        if (geo.isNumberValue()) {
            NumberValue num = (NumberValue) geo;
            inputArray[i] = num.getDouble();
        } else {
            outputList.setUndefined();
            return;
        }
    }

    if (rankingAlgorithm == null)
        rankingAlgorithm = new NaturalRanking(TiesStrategy.AVERAGE);

    outputArray = rankingAlgorithm.rank(inputArray);

    // copy the ranks back into a list
    outputList.setDefined(true);
    outputList.clear();
    for (int i = 0; i < size; i++) {
        outputList.add(new GeoNumeric(cons, outputArray[i]));
    }
}

From source file:geogebra.common.kernel.statistics.AlgoTiedRank.java

@Override
public final void compute() {

    size = inputList.size();//from   w  ww.j a  va 2  s  . co  m
    if (!inputList.isDefined() || size == 0) {
        outputList.setUndefined();
        return;
    }

    inputArray = new double[size];

    // load input value array from geoList
    for (int i = 0; i < size; i++) {
        GeoElement geo = inputList.get(i);
        if (geo instanceof NumberValue) {
            NumberValue num = (NumberValue) geo;
            inputArray[i] = num.getDouble();
        } else {
            outputList.setUndefined();
            return;
        }
    }

    if (rankingAlgorithm == null)
        rankingAlgorithm = new NaturalRanking(TiesStrategy.AVERAGE);

    outputArray = rankingAlgorithm.rank(inputArray);

    // copy the ranks back into a list
    outputList.setDefined(true);
    outputList.clear();
    for (int i = 0; i < size; i++) {
        outputList.add(new GeoNumeric(cons, outputArray[i]));
    }
}