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


Java Pair.getKey方法代码示例

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


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

示例1: inverseCumulativeProbability

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }

    double probability = 0;
    double x = getSupportLowerBound();
    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        if (sample.getValue() == 0.0) {
            continue;
        }

        probability += sample.getValue();
        x = sample.getKey();

        if (probability >= p) {
            break;
        }
    }

    return x;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:EnumeratedRealDistribution.java

示例2: getWordIndexAndRelativePosition

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/** Returns a pair of indices specifying the word index for the given caretOffset and the 
	 * index of caretOffset relative to this word. (-1, -1) is returned if no word is found for xIndex. */
	private Pair<Integer, Integer> getWordIndexAndRelativePosition(int caretOffset) {
		TrpTextLineType tl = getLineObject(text.getLineAtOffset(caretOffset));
//		logger.debug("tl = "+tl);
		
		int xIndex = getXIndex(caretOffset);
				
//		String lineText = text.getLine(currentLineIndex);
				
		int i=0; // the current word index
		int l=0; // the length of the text already parsed through
		for (Pair<Integer, Integer> p : getWordRanges(tl).values()) {
			if (xIndex >= p.getKey() && xIndex <= p.getValue()) {
				return Pair.of(i, xIndex-l);
			}
			l += (p.getValue()-p.getKey())+1;
			++i;
		}
		
		return Pair.of(-1, -1);
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:23,代码来源:WordTranscriptionWidget.java

示例3: getNumRepresentation

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * Get a number representation from the object provided.
 *
 * @param att object to try and represent
 * @return number that represents
 */
public static Double getNumRepresentation(final Object att) {
    // is an Numeric value
    if (Number.class.isAssignableFrom(att.getClass())) {
        return ((Number) att).doubleValue();
    } else { // is a String
        Pair<Boolean, Boolean> num1 = LoomQueryUtils.isNumber(att.toString().trim());
        String s1 = att.toString().trim();
        if (num1.getKey()) {
            return Double.parseDouble(s1);
        } else {
            return Double.valueOf(s1);
        }
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:21,代码来源:LoomQueryUtils.java

示例4: cumulativeProbability

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public double cumulativeProbability(final int x) {
    double probability = 0;

    for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() <= x) {
            probability += sample.getValue();
        }
    }

    return probability;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:EnumeratedIntegerDistribution.java

示例5: getNumericalMean

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @return {@code sum(singletons[i] * probabilities[i])}
 */
public double getNumericalMean() {
    double mean = 0;

    for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) {
        mean += sample.getValue() * sample.getKey();
    }

    return mean;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:EnumeratedIntegerDistribution.java

示例6: getNumericalVariance

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @return {@code sum((singletons[i] - mean) ^ 2 * probabilities[i])}
 */
public double getNumericalVariance() {
    double mean = 0;
    double meanOfSquares = 0;

    for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) {
        mean += sample.getValue() * sample.getKey();
        meanOfSquares += sample.getValue() * sample.getKey() * sample.getKey();
    }

    return meanOfSquares - mean * mean;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:17,代码来源:EnumeratedIntegerDistribution.java

示例7: getSupportLowerBound

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Returns the lowest value with non-zero probability.
 *
 * @return the lowest value with non-zero probability.
 */
public int getSupportLowerBound() {
    int min = Integer.MAX_VALUE;
    for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() < min && sample.getValue() > 0) {
            min = sample.getKey();
        }
    }

    return min;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:EnumeratedIntegerDistribution.java

示例8: getSupportUpperBound

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Returns the highest value with non-zero probability.
 *
 * @return the highest value with non-zero probability.
 */
public int getSupportUpperBound() {
    int max = Integer.MIN_VALUE;
    for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() > max && sample.getValue() > 0) {
            max = sample.getKey();
        }
    }

    return max;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:EnumeratedIntegerDistribution.java

示例9: cumulativeProbability

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public double cumulativeProbability(final double x) {
    double probability = 0;

    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() <= x) {
            probability += sample.getValue();
        }
    }

    return probability;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:EnumeratedRealDistribution.java

示例10: getNumericalMean

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @return {@code sum(singletons[i] * probabilities[i])}
 */
public double getNumericalMean() {
    double mean = 0;

    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        mean += sample.getValue() * sample.getKey();
    }

    return mean;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:EnumeratedRealDistribution.java

示例11: getNumericalVariance

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @return {@code sum((singletons[i] - mean) ^ 2 * probabilities[i])}
 */
public double getNumericalVariance() {
    double mean = 0;
    double meanOfSquares = 0;

    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        mean += sample.getValue() * sample.getKey();
        meanOfSquares += sample.getValue() * sample.getKey() * sample.getKey();
    }

    return meanOfSquares - mean * mean;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:17,代码来源:EnumeratedRealDistribution.java

示例12: getSupportLowerBound

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Returns the lowest value with non-zero probability.
 *
 * @return the lowest value with non-zero probability.
 */
public double getSupportLowerBound() {
    double min = Double.POSITIVE_INFINITY;
    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() < min && sample.getValue() > 0) {
            min = sample.getKey();
        }
    }

    return min;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:EnumeratedRealDistribution.java

示例13: getSupportUpperBound

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Returns the highest value with non-zero probability.
 *
 * @return the highest value with non-zero probability.
 */
public double getSupportUpperBound() {
    double max = Double.NEGATIVE_INFINITY;
    for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
        if (sample.getKey() > max && sample.getValue() > 0) {
            max = sample.getKey();
        }
    }

    return max;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:EnumeratedRealDistribution.java

示例14: bothAreNumbers

import org.apache.commons.math3.util.Pair; //导入方法依赖的package包/类
private static boolean bothAreNumbers(final Pair<Boolean, Boolean> num1, final Pair<Boolean, Boolean> num2) {
    return num1.getKey() && num2.getKey();
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:4,代码来源:LoomQueryUtils.java


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