本文整理汇总了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;
}
示例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;
}