org.apache.commons.math3.stat.ranking.TiesStrategy Java Examples

The following examples show how to use org.apache.commons.math3.stat.ranking.TiesStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XDataFrameRank.java    From morpheus-core with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the rank array for the values specified
 * @param values    the values to rank
 * @return          the ranks of input array
 */
static double[] rank(double[] values) {
    final NaNStrategy nanStrategy = (NaNStrategy)optionsMap.get(NaNStrategy.class).get(DataFrameOptions.getNanStrategy());
    final TiesStrategy tieStrategy = (TiesStrategy)optionsMap.get(TiesStrategy.class).get(DataFrameOptions.getTieStrategy());
    if (nanStrategy == null) throw new DataFrameException("Unsupported NaN strategy specified: " + DataFrameOptions.getNanStrategy());
    if (tieStrategy == null) throw new DataFrameException("Unsupported tie strategy specified: " + DataFrameOptions.getTieStrategy());
    final NaturalRanking ranking = new NaturalRanking(nanStrategy, tieStrategy);
    return ranking.rank(values);
}
 
Example #2
Source File: MatrixTools.java    From systemsgenetics with GNU General Public License v3.0 5 votes vote down vote up
public static void rankColumns(DoubleMatrix2D matrix) {
    RankingAlgorithm COV_RANKER_TIE = new NaturalRanking(NaNStrategy.FAILED, TiesStrategy.AVERAGE);
    
    for (int c = 0; c < matrix.columns(); c++) {
        double[] rank = COV_RANKER_TIE.rank(matrix.viewColumn(c).toArray());
        for (int r = 0; r < matrix.rows(); r++) {
            matrix.set(r, c, (rank[r]));
        }
    }
}
 
Example #3
Source File: MannWhitneyUTest2.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
public MannWhitneyUTest2() {
	naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
			TiesStrategy.AVERAGE);
}
 
Example #4
Source File: DoubleMatrixDataset.java    From systemsgenetics with GNU General Public License v3.0 3 votes vote down vote up
public DoubleMatrixDataset<R, C> createColumnForceNormalDuplicate() {

		DoubleMatrixDataset<R, C> newDataset = new DoubleMatrixDataset<>(hashRows, hashCols);

		NaturalRanking ranking = new NaturalRanking(NaNStrategy.FAILED,
				TiesStrategy.AVERAGE);

		for (int c = 0; c < matrix.columns(); ++c) {

			double[] col = matrix.viewColumn(c).toArray();

			double mean = JSci.maths.ArrayMath.mean(col);
			double stdev = JSci.maths.ArrayMath.standardDeviation(col);

			double[] rankedValues = ranking.rank(col);

			for (int s = 0; s < matrix.rows(); s++) {
				double pValue = (0.5d + rankedValues[s] - 1d) / (double) (rankedValues.length);

				newDataset.setElementQuick(s, c, mean + cern.jet.stat.Probability.normalInverse(pValue) * stdev);
			}

		}

		return newDataset;

	}
 
Example #5
Source File: DoubleMatrixDataset.java    From systemsgenetics with GNU General Public License v3.0 3 votes vote down vote up
public DoubleMatrixDataset<R, C> createRowForceNormalDuplicate() {

		DoubleMatrixDataset<R, C> newDataset = new DoubleMatrixDataset<>(hashRows, hashCols);

		NaturalRanking ranking = new NaturalRanking(NaNStrategy.FAILED,
				TiesStrategy.AVERAGE);

		for (int r = 0; r < matrix.rows(); ++r) {

			double[] row = matrix.viewRow(r).toArray();

			double mean = JSci.maths.ArrayMath.mean(row);
			double stdev = JSci.maths.ArrayMath.standardDeviation(row);

			double[] rankedValues = ranking.rank(row);

			for (int s = 0; s < matrix.columns(); s++) {
				double pValue = (0.5d + rankedValues[s] - 1d) / (double) (rankedValues.length);

				newDataset.setElementQuick(r, s, mean + cern.jet.stat.Probability.normalInverse(pValue) * stdev);
			}

		}

		return newDataset;

	}
 
Example #6
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public WilcoxonSignedRankTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #7
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public WilcoxonSignedRankTest(final NaNStrategy nanStrategy,
                              final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #8
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #9
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #10
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public WilcoxonSignedRankTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #11
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public WilcoxonSignedRankTest(final NaNStrategy nanStrategy,
                              final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #12
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #13
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #14
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public WilcoxonSignedRankTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #15
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public WilcoxonSignedRankTest(final NaNStrategy nanStrategy,
                              final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #16
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #17
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #18
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public WilcoxonSignedRankTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #19
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public WilcoxonSignedRankTest(final NaNStrategy nanStrategy,
                              final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #20
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #21
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #22
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public WilcoxonSignedRankTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #23
Source File: WilcoxonSignedRankTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public WilcoxonSignedRankTest(final NaNStrategy nanStrategy,
                              final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #24
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #25
Source File: MannWhitneyUTest.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #26
Source File: MannWhitneyUTest2.java    From systemsgenetics with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy specifies the strategy that should be used for
 * Double.NaN's
 * @param tiesStrategy specifies the strategy that should be used for ties
 */
public MannWhitneyUTest2(final NaNStrategy nanStrategy,
		final TiesStrategy tiesStrategy) {
	naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #27
Source File: patchedMannWhitneyUTest.java    From coming with MIT License 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #28
Source File: Elixir_0022_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
Example #29
Source File: Elixir_0022_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * Create a test instance using the given strategies for NaN's and ties.
 * Only use this if you are sure of what you are doing.
 *
 * @param nanStrategy
 *            specifies the strategy that should be used for Double.NaN's
 * @param tiesStrategy
 *            specifies the strategy that should be used for ties
 */
public MannWhitneyUTest(final NaNStrategy nanStrategy,
                        final TiesStrategy tiesStrategy) {
    naturalRanking = new NaturalRanking(nanStrategy, tiesStrategy);
}
 
Example #30
Source File: Elixir_0022_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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.
 */
public MannWhitneyUTest() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}