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


Java GammaDistribution类代码示例

本文整理汇总了Java中org.apache.commons.math.distribution.GammaDistribution的典型用法代码示例。如果您正苦于以下问题:Java GammaDistribution类的具体用法?Java GammaDistribution怎么用?Java GammaDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: calculateCategoryRates

import org.apache.commons.math.distribution.GammaDistribution; //导入依赖的package包/类
/**
 * discretisation of gamma distribution with equal proportions in each
 * category
 * @param node
 */
protected void calculateCategoryRates(final Node node) {
    double propVariable = 1.0;
    int cat = 0;

    if (/*invarParameter != null && */invarParameter.getValue() > 0) {
        if (hasPropInvariantCategory) {
            categoryRates[0] = 0.0;
            categoryProportions[0] = invarParameter.getValue();
        }
        propVariable = 1.0 - invarParameter.getValue();
        if (hasPropInvariantCategory) {
            cat = 1;
        }
    }

    if (shapeParameter != null) {

        final double a = shapeParameter.getValue();
        double mean = 0.0;
        final int gammaCatCount = categoryCount - cat;

        final GammaDistribution g = new GammaDistributionImpl(a, 1.0 / a);
        for (int i = 0; i < gammaCatCount; i++) {
            try {
                // RRB: alternative implementation that seems equally good in
                // the first 5 significant digits, but uses a standard distribution object
            	if (useBeast1StyleGamma) {
                    categoryRates[i + cat] = GammaDistributionQuantile((2.0 * i + 1.0) / (2.0 * gammaCatCount), a, 1.0 / a);
            	} else {
            		categoryRates[i + cat] = g.inverseCumulativeProbability((2.0 * i + 1.0) / (2.0 * gammaCatCount));
            	}

            } catch (Exception e) {
                e.printStackTrace();
                Log.err.println("Something went wrong with the gamma distribution calculation");
                System.exit(-1);
            }
            mean += categoryRates[i + cat];

            categoryProportions[i + cat] = propVariable / gammaCatCount;
        }

        mean = (propVariable * mean) / gammaCatCount;

        for (int i = 0; i < gammaCatCount; i++) {

            categoryRates[i + cat] /= mean;
        }
    } else {
        categoryRates[cat] = 1.0 / propVariable;
        categoryProportions[cat] = propVariable;
    }


    ratesKnown = true;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:62,代码来源:SiteModel.java

示例2: calculateCategoryRates

import org.apache.commons.math.distribution.GammaDistribution; //导入依赖的package包/类
/**
 * discretisation of gamma distribution with equal proportions in each
 * category
 * @param node
 */
protected void calculateCategoryRates(final Node node) {
    double propVariable = 1.0;
    int cat = 0;

    if (/*invarParameter != null && */invarParameter.getValue() > 0) {
        if (hasPropInvariantCategory) {
            categoryRates[0] = 0.0;
            categoryProportions[0] = invarParameter.getValue();
        }
        propVariable = 1.0 - invarParameter.getValue();
        if (hasPropInvariantCategory) {
            cat = 1;
        }
    }

    if (shapeParameter != null) {

        final double a = shapeParameter.getValue();
        double mean = 0.0;
        final int gammaCatCount = categoryCount - cat;

        final GammaDistribution g = new GammaDistributionImpl(a, 1.0 / a);
        for (int i = 0; i < gammaCatCount; i++) {
            try {
                // RRB: alternative implementation that seems equally good in
                // the first 5 significant digits, but uses a standard distribution object
            	if (useBeast1StyleGamma) {
                    categoryRates[i + cat] = GammaDistributionQuantile((2.0 * i + 1.0) / (2.0 * gammaCatCount), a, 1.0 / a);
            	} else {
            		categoryRates[i + cat] = g.inverseCumulativeProbability((2.0 * i + 1.0) / (2.0 * gammaCatCount));
            	}

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("Something went wrong with the gamma distribution calculation");
                System.exit(-1);
            }
            mean += categoryRates[i + cat];

            categoryProportions[i + cat] = propVariable / gammaCatCount;
        }

        mean = (propVariable * mean) / gammaCatCount;

        for (int i = 0; i < gammaCatCount; i++) {

            categoryRates[i + cat] /= mean;
        }
    } else {
        categoryRates[cat] = 1.0 / propVariable;
        categoryProportions[cat] = propVariable;
    }


    ratesKnown = true;
}
 
开发者ID:rbouckaert,项目名称:YABBY,代码行数:62,代码来源:SiteModel.java


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