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

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

Introduction

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

Prototype

TiesStrategy AVERAGE

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

Click Source Link

Document

Ties get the average of applicable ranks

Usage

From source file:gedi.util.math.stat.testing.WilcoxonUnpaired.java

/**
 * Create a test instance where NaN's are left in place and ties get
 * the average of applicable ranks. Use this unless you are very sure
 * of what you are doing./*from w w w  .jav a  2  s .  c  o  m*/
 */
public WilcoxonUnpaired() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED, TiesStrategy.AVERAGE);
}

From source file:MannWhitneyUTest.java

/**
 * Create a test instance using where NaN's are left in place and ties get
 * the average of applicable ranks. Use this unless you are very sure of
 * what you are doing./* ww w. j  a v a 2  s.  com*/
 */
public MannWhitneyUTest() {
    System.out.println("1");
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED, TiesStrategy.AVERAGE);
}

From source file:com.itemanalysis.jmetrik.stats.ranking.RankingAnalysis.java

/**
 * Adds columns to database for storing ranks, ntiles, and normal scores.
 * A prefix is added to the variable name to indicate the type of variable.
 *
 * These prefixes are used to update the proper variables in the database (see compute()).
 *
 * @throws SQLException/*from  w w  w .ja  v  a2s .  c o  m*/
 * @throws IllegalArgumentException
 */
//    public void addColumnsToDb()throws SQLException, IllegalArgumentException{
//
//        int numberOfColumns = dao.getColumnCount(conn, tableName);
//        int columnNumber = numberOfColumns+1;
//
//        String newVariableLabel = "Rank";
//        if(blom) newVariableLabel = "Blom Normal Score";
//        if(tukey) newVariableLabel = "Tukey Normal Score";
//        if(vdw) newVariableLabel = "van der Waerden Normal Score";
//        if(ntiles) newVariableLabel = "Quantiles: " + numGroups + " groups";
//
//        newVariable = new VariableInfo(newVariableName, newVariableLabel, VariableType.NOT_ITEM, VariableType.DOUBLE, columnNumber++, "");
//        dao.addColumnToDb(conn, tableName, newVariable);
//
//    }

protected String doInBackground() {
    sw = new StopWatch();
    this.firePropertyChange("status", "", "Running Ranking...");
    this.firePropertyChange("progress-on", null, null);
    String results = "";
    try {

        //get variable info from db
        tableName = new DataTableName(command.getPairedOptionList("data").getStringAt("table"));
        VariableTableName variableTableName = new VariableTableName(tableName.toString());
        String selectVariable = command.getFreeOption("variable").getString();
        variable = dao.getVariableAttributes(conn, variableTableName, selectVariable);

        newVariableName = command.getFreeOption("name").getString();

        initializeProgress();

        String ties = command.getSelectOneOption("ties").getSelectedArgument();
        if (ties.equals("sequential")) {
            tiesStrategy = TiesStrategy.SEQUENTIAL;
        } else if (ties.equals("min")) {
            tiesStrategy = TiesStrategy.MINIMUM;
        } else if (ties.equals("max")) {
            tiesStrategy = TiesStrategy.MAXIMUM;
        } else if (ties.equals("average")) {
            tiesStrategy = TiesStrategy.AVERAGE;
        } else if (ties.equals("random")) {
            tiesStrategy = TiesStrategy.RANDOM;
        }

        String type = command.getSelectOneOption("type").getSelectedArgument();
        if ("blom".equals(type)) {
            blom = true;
        } else if ("tukey".equals(type)) {
            tukey = true;
        } else if ("vdw".equals(type)) {
            vdw = true;
        } else if ("ntiles".equals(type)) {
            ntiles = true;
            if (command.getFreeOption("ntiles").hasValue()) {
                numGroups = command.getFreeOption("ntiles").getInteger();
            } else {
                rank = true;
            }
        } else {
            rank = true;
        }

        if (blom || tukey || vdw)
            normScore = new NormalScores();
        ascending = command.getSelectOneOption("order").isValueSelected("asc");

        //            addColumnsToDb();
        results = compute();

        firePropertyChange("status", "", "Done: " + sw.getElapsedTime());
        firePropertyChange("progress-off", null, null); //make statusbar progress not visible

    } catch (Throwable t) {
        logger.fatal(t.getMessage(), t);
        theException = t;
    }
    return results;
}

From source file:org.caleydo.view.enroute.correlation.wilcoxon.WilcoxonManualResultPage.java

@Override
public void pageChanged(PageChangedEvent event) {
    if (event.getSelectedPage() == this) {
        WilcoxonRankSumTestWizard wizard = (WilcoxonRankSumTestWizard) getWizard();
        DataCellInfo targetInfo = wizard.getTargetInfo();

        // java.util.List<WilcoxonResult> resultList = WilcoxonUtil.applyWilcoxonToAllElements(
        // wizard.getSourceClassifier(), wizard.getSourceInfo(), targetInfo.columnPerspective);
        ///*from ww w. j a  va2 s  . c  om*/
        // for (WilcoxonResult r : resultList) {
        // System.out.println(r.p);
        // }
        // System.out.println("NumElements: " + resultList.size());

        // WilcoxonUtil.calcWilcoxonRankSumTest(sourceInfo, classifier, targetInfo)

        SimpleIDClassifier derivedClassifier = wizard.getDerivedIDClassifier();
        MannWhitneyUTest test = new MannWhitneyUTest(NaNStrategy.REMOVED, TiesStrategy.AVERAGE);
        double[] values1 = WilcoxonUtil.getSampleValuesArray(targetInfo, derivedClassifier.getClass1IDs());
        double[] values2 = WilcoxonUtil.getSampleValuesArray(targetInfo, derivedClassifier.getClass2IDs());

        double u = test.mannWhitneyU(values1, values2);
        double p = test.mannWhitneyUTest(values1, values2);

        resultsWidget.update(wizard.getSourceInfo(), targetInfo,
                new WilcoxonResult(p, u, wizard.getSourceClassifier(), derivedClassifier));

        // resultsWidget.updateClassSummary(0, values1, derivedClassifier.getDataClasses().get(0));
        // resultsWidget.updateClassSummary(1, values2, derivedClassifier.getDataClasses().get(1));
        //
        // resultsWidget.updateStatistics(u, p);
    }

}

From source file:org.gitools.analysis.stats.test.MannWhitneyWilcoxonTest.java

public MannWhitneyWilcoxonTest() {
    super("mannWhitneyWilcoxon", GroupComparisonResult.class);
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED, TiesStrategy.AVERAGE);
}

From source file:umcg.genetica.math.stats.MannWhitneyUTest2.java

public MannWhitneyUTest2() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED, TiesStrategy.AVERAGE);
}