当前位置: 首页>>代码示例>>Java>>正文


Java NaNStrategy.FIXED属性代码示例

本文整理汇总了Java中org.apache.commons.math.stat.ranking.NaNStrategy.FIXED属性的典型用法代码示例。如果您正苦于以下问题:Java NaNStrategy.FIXED属性的具体用法?Java NaNStrategy.FIXED怎么用?Java NaNStrategy.FIXED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math.stat.ranking.NaNStrategy的用法示例。


在下文中一共展示了NaNStrategy.FIXED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rank

public static double[] rank(double[] data) {

        // Array recording initial positions of data to be ranked
        IntDoublePair[] ranks = new IntDoublePair[data.length];
        for (int i = 0; i < data.length; i++) {
            ranks[i] = new IntDoublePair(data[i], i);
        }

        // Recode, remove or record positions of NaNs
        List<Integer> nanPositions = null;
        switch (nanStrategy) {
            case MAXIMAL: // Replace NaNs with +INFs
                recodeNaNs(ranks, Double.POSITIVE_INFINITY);
                break;
            case MINIMAL: // Replace NaNs with -INFs
                recodeNaNs(ranks, Double.NEGATIVE_INFINITY);
                break;
            case REMOVED: // Drop NaNs from data
                ranks = removeNaNs(ranks);
                break;
            case FIXED:   // Record positions of NaNs
                nanPositions = getNanPositions(ranks);
                break;
            default: // this should not happen unless NaNStrategy enum is changed
                throw MathRuntimeException.createInternalError(null);
        }

        // Sort the IntDoublePairs
        Arrays.sort(ranks);
        
        // Walk the sorted array, filling output array using sorted positions,
        // resolving ties as we go
        double[] out = new double[ranks.length];
        int pos = 1;  // position in sorted array
        out[ranks[0].getPosition()] = pos;
        List<Integer> tiesTrace = new ArrayList<Integer>();
        tiesTrace.add(ranks[0].getPosition());
        for (int i = 1; i < ranks.length; i++) {
            if (Double.compare(ranks[i].getValue(), ranks[i - 1].getValue()) > 0) {
                // tie sequence has ended (or had length 1)
                pos = i + 1;
                if (tiesTrace.size() > 1) {  // if seq is nontrivial, resolve
                    resolveTie(out, tiesTrace);
                }
                tiesTrace = new ArrayList<Integer>();
                tiesTrace.add(ranks[i].getPosition());
            } else {
                // tie sequence continues
                tiesTrace.add(ranks[i].getPosition());
            }
            out[ranks[i].getPosition()] = pos;
        }
        if (tiesTrace.size() > 1) {  // handle tie sequence at end
            resolveTie(out, tiesTrace);
        }
        if (nanStrategy == NaNStrategy.FIXED) {
            restoreNaNs(out, nanPositions);
        }
        return out;
    }
 
开发者ID:mgerlich,项目名称:MetFusion,代码行数:60,代码来源:MathTest.java

示例2: WilcoxonSignedRankTestImpl

/**
 * 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 WilcoxonSignedRankTestImpl() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:WilcoxonSignedRankTestImpl.java

示例3: MannWhitneyUTestImpl

/**
 * 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 MannWhitneyUTestImpl() {
    naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
            TiesStrategy.AVERAGE);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:MannWhitneyUTestImpl.java


注:本文中的org.apache.commons.math.stat.ranking.NaNStrategy.FIXED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。