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

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

Introduction

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

Prototype

TiesStrategy SEQUENTIAL

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

Click Source Link

Document

Ties assigned sequential ranks in order of occurrence

Usage

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. j  ava  2  s  .co 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;
}