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


Java MathUtils.log方法代码示例

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


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

示例1: getEntropy

import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
 * Return the entropy of a given set of classes.
 * @param counts number of elements in each class.
 * @param size total number of elements. (denominator of the probability)
 * @return the entropy of a given set of classes.
 */
protected double getEntropy(HashMap<?, Integer> counts, int size)
{
	double dSize = (double) size;
	double h = 0;
	for (Integer count : counts.values())
	{
		double prob = count/dSize;
		h -= prob * MathUtils.log(2, prob);
	}
	return h;
}
 
开发者ID:williamleif,项目名称:PSRToolbox,代码行数:18,代码来源:GeneralizedNormalizedShannonEntropy.java

示例2: getPositionToScoreMap

import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
 * Returns a map PTM localization &gt; score.
 *
 * @param peptide the peptide of interest
 * @param noModPeptide the peptide without the variable modification of
 * interest
 * @param refPTM the PTM of interest
 * @param annotationPreferences the global annotation preferences
 * @param specificAnnotationPreferences the annotation preferences specific
 * to this peptide and spectrum
 * @param spectrumAnnotator the spectrum annotator which should be used to
 * annotate the spectrum
 * @param spectrum the spectrum of interest
 * @param spectrumMap the map of the extracted spectra: depth &gt; extracted
 * spectrum
 * @param possibleSites the possible modification sites
 *
 * @return a map PTM localization &gt; score
 *
 * @throws org.apache.commons.math.MathException exception thrown whenever a
 * math error occurred while computing the score or estimating the noise level
 * @throws java.lang.InterruptedException exception thrown if the thread is
 * interrupted
 */
public static HashMap<Integer, HashMap<Integer, Double>> getPositionToScoreMap(Peptide peptide, Peptide noModPeptide, ArrayList<Integer> possibleSites,
        MSnSpectrum spectrum, HashMap<Integer, MSnSpectrum> spectrumMap, AnnotationSettings annotationPreferences, SpecificAnnotationSettings specificAnnotationPreferences, PeptideSpectrumAnnotator spectrumAnnotator, PTM refPTM) throws MathException, InterruptedException {

    HashMap<Integer, HashMap<Integer, Double>> positionToScoreMap = new HashMap<Integer, HashMap<Integer, Double>>();

    int N = 0;

    for (ArrayList<Ion> fragmentIons : spectrumAnnotator.getExpectedIons(specificAnnotationPreferences, peptide).values()) {
        N += fragmentIons.size();
    }

    String sequence = noModPeptide.getSequence();
    int sequenceLength = sequence.length();

    for (int i = 0; i < spectrumMap.size(); i++) {

        double p = ((double) i + 1) / 100;

        for (int pos : possibleSites) {
            Peptide tempPeptide = new Peptide(noModPeptide.getSequence(), noModPeptide.getModificationMatches());
            int position;
            if (pos == 0) {
                position = 1;
            } else if (pos == sequenceLength + 1) {
                position = sequenceLength;
            } else {
                position = pos;
            }
            tempPeptide.addModificationMatch(new ModificationMatch(refPTM.getName(), true, position));

            ArrayList<IonMatch> matches = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences, specificAnnotationPreferences,
                    spectrumMap.get(i), tempPeptide, false);
            int n = matches.size();

            BinomialDistribution distribution = new BinomialDistribution(N, p);
            Double bigP = distribution.getDescendingCumulativeProbabilityAt((double) n);
            Double score = -10 * MathUtils.log(10, bigP);
            HashMap<Integer, Double> scoresAtPosition = positionToScoreMap.get(pos);
            if (scoresAtPosition == null) {
                scoresAtPosition = new HashMap<Integer, Double>(2);
                positionToScoreMap.put(pos, scoresAtPosition);
            }
            scoresAtPosition.put(i + 1, score);
        }
    }
    return positionToScoreMap;
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:72,代码来源:AScore.java

示例3: log

import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
public static double log(double x, double base) {

    //Method cannot be called directly as R and Apache Commons Math argument order
    // are reversed
    return MathUtils.log(base, x);
  }
 
开发者ID:CompEvol,项目名称:beastshell,代码行数:7,代码来源:MathExt.java

示例4: log2

import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
public static double log2(double d) {
  return MathUtils.log(2, d);
}
 
开发者ID:CompEvol,项目名称:beastshell,代码行数:4,代码来源:MathExt.java


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