當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair.getValue方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.util.Pair.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Pair.getValue方法的具體用法?Java Pair.getValue怎麽用?Java Pair.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.util.Pair的用法示例。


在下文中一共展示了Pair.getValue方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: EnumeratedDistribution

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Create an enumerated distribution using the given random number generator
 * and probability mass function enumeration.
 *
 * @param rng random number generator.
 * @param pmf probability mass function enumerated as a list of <T, probability>
 * pairs.
 * @throws NotPositiveException if any of the probabilities are negative.
 * @throws NotFiniteNumberException if any of the probabilities are infinite.
 * @throws NotANumberException if any of the probabilities are NaN.
 * @throws MathArithmeticException all of the probabilities are 0.
 */
public EnumeratedDistribution(final RandomGenerator rng, final List<Pair<T, Double>> pmf)
    throws NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException {
    random = rng;

    singletons = new ArrayList<T>(pmf.size());
    final double[] probs = new double[pmf.size()];

    for (int i = 0; i < pmf.size(); i++) {
        final Pair<T, Double> sample = pmf.get(i);
        singletons.add(sample.getKey());
        final double p = sample.getValue();
        if (p < 0) {
            throw new NotPositiveException(sample.getValue());
        }
        if (Double.isInfinite(p)) {
            throw new NotFiniteNumberException(p);
        }
        if (Double.isNaN(p)) {
            throw new NotANumberException();
        }
        probs[i] = p;
    }

    probabilities = MathArrays.normalizeArray(probs, 1.0);

    cumulativeProbabilities = new double[probabilities.length];
    double sum = 0;
    for (int i = 0; i < probabilities.length; i++) {
        sum += probabilities[i];
        cumulativeProbabilities[i] = sum;
    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:45,代碼來源:EnumeratedDistribution.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


注:本文中的org.apache.commons.math3.util.Pair.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。