List of usage examples for org.apache.commons.math3.stat.ranking TiesStrategy MINIMUM
TiesStrategy MINIMUM
To view the source code for org.apache.commons.math3.stat.ranking TiesStrategy MINIMUM.
Click Source Link
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 ww. j a v a 2s . c om * @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:weka.filters.supervised.attribute.ifcfilter.numericalgorithme.Ntil.java
/** * Computes the index of the n-tile.//from ww w. j a v a 2 s. c o m * * @param table double array containing the target values and sorted numeric * values. * @param ntil int sets number of n-tile. */ public void set(double[][] table, int ntil) { numData = new double[3][table[1].length]; numData[0] = table[0]; numData[1] = table[1]; PercentileRank ranking = new PercentileRank(NaNStrategy.REMOVED, TiesStrategy.MINIMUM); double[] ranks = ranking.rank(table[1]); int numq = 0; double qold = 0; double qnew = 0; int n11 = 0; for (int i = 0; i < table[1].length; i++) { qnew = java.lang.Math.floor(ranks[i] * ntil) + 1; if (qold != qnew) { numq++; } qold = qnew; numData[2][i] = qnew; // //numData[2][i] = java.lang.Math.floor(i * ntil / table[1].length) + 1; if (table[0][i] == 1 && numData[2][i] == 1) { n11++; } } String[] labels = { "Y", "X", "N" }; //System.out.print(contingencyCrosstable.ar2s(numData, labels)); new Date(); }