本文整理汇总了Java中beast.core.parameter.BooleanParameter类的典型用法代码示例。如果您正苦于以下问题:Java BooleanParameter类的具体用法?Java BooleanParameter怎么用?Java BooleanParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BooleanParameter类属于beast.core.parameter包,在下文中一共展示了BooleanParameter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initAndValidate
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
BooleanParameter indicators = indicatorsInput.get();
TreeInterface tree = treeInput.get();
int nodeCount = tree.getNodeCount();
rootNodeNumber = nodeCount - 1;
ratesArray = new double[nodeCount];
storedRatesArray = new double[nodeCount];
noCache = noCacheInput.get().booleanValue();
RealParameter rates = branchRatesInput.get();
rates.setDimension(rootNodeNumber);
indicators.setDimension(rootNodeNumber);
if (rates.lowerValueInput.get() == null || rates.lowerValueInput.get() < 0.0) {
rates.setLower(0.0);
}
if (rates.upperValueInput.get() == null || rates.upperValueInput.get() < 0.0) {
rates.setUpper(Double.MAX_VALUE);
}
needsUpdate = true;
}
开发者ID:genomescale,项目名称:starbeast2,代码行数:26,代码来源:RandomLocalRates.java
示例2: calculateUnscaledBranchRates
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
/**
* This is a recursive function that does the work of
* calculating the unscaled branch rates across the tree
* taking into account the indicator variables.
*
* @param node the node
* @param rate the rate of the parent node
*/
private void calculateUnscaledBranchRates(Node node, double rate, BooleanParameter indicators, RealParameter rates) {
int nodeNumber = getNr(node);
if (!node.isRoot()) {
if (indicators.getValue(nodeNumber)) {
if (ratesAreMultipliers) {
rate *= rates.getValue(nodeNumber);
} else {
rate = rates.getValue(nodeNumber);
}
}
}
unscaledBranchRates[nodeNumber] = rate;
if (!node.isLeaf()) {
calculateUnscaledBranchRates(node.getLeft(), rate, indicators, rates);
calculateUnscaledBranchRates(node.getRight(), rate, indicators, rates);
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:RandomLocalClockModel.java
示例3: initAndValidate
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
m_fScaleFactor = scaleFactorInput.get();
m_bIsTreeScaler = (treeInput.get() != null);
upper = scaleUpperLimit.get();
lower = scaleLowerLimit.get();
final BooleanParameter indicators = indicatorInput.get();
if (indicators != null) {
if (m_bIsTreeScaler) {
throw new IllegalArgumentException("indicator is specified which has no effect for scaling a tree");
}
final int dataDim = parameterInput.get().getDimension();
final int indsDim = indicators.getDimension();
if (!(indsDim == dataDim || indsDim + 1 == dataDim)) {
throw new IllegalArgumentException("indicator dimension not compatible from parameter dimension");
}
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:20,代码来源:ScaleOperator.java
示例4: proposal
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
/**
* Change the parameter and return the hastings ratio.
* Flip (Switch a 0 to 1 or 1 to 0) for a random bit in a bit vector.
* Return the hastings ratio which makes all subsets of vectors with the same number of 1 bits
* equiprobable, unless !usesPriorOnSum , then all configurations are equiprobable
*/
@Override
public double proposal() {
final BooleanParameter p = parameterInput.get(this);
final int dim = p.getDimension();
double sum = 0.0;
if (usesPriorOnSum) {
for (int i = 0; i < dim; i++) {
if (p.getValue(i)) sum += 1;
}
}
final int pos = Randomizer.nextInt(dim);
final boolean value = p.getValue(pos);
double logq = 0.0;
if (!value) {
p.setValue(pos, true);
if (usesPriorOnSum) {
logq = -Math.log((dim - sum) / (sum + 1));
}
} else {
//assert value;
p.setValue(pos, false);
if (usesPriorOnSum) {
logq = -Math.log(sum / (dim - sum + 1));
}
}
return logq;
}
开发者ID:CompEvol,项目名称:beast2,代码行数:44,代码来源:BitFlipOperator.java
示例5: initAndValidate
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
List<Function> valuable = functionInput.get();
mode = Mode.integer_mode;
for (Function v : valuable) {
if (!(v instanceof IntegerParameter || v instanceof BooleanParameter)) {
mode = Mode.double_mode;
}
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:11,代码来源:Sum.java
示例6: testSum
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
@Test
public void testSum() {
RealParameter p1 = new RealParameter("1.0 2.0");
Sum sum = new Sum();
// single argument sum
sum.initByName("arg", p1);
double v = sum.getArrayValue();
assertEquals(3.0, v, 1e-10);
// multiple argument sum
sum = new Sum();
RealParameter p2 = new RealParameter("2.0 2.5");
sum.initByName("arg", p1, "arg", p2);
v = sum.getArrayValue();
assertEquals(7.5, v, 1e-10);
// multiple same argument sum
sum = new Sum();
sum.initByName("arg", p1, "arg", p1);
v = sum.getArrayValue();
assertEquals(6.0, v, 1e-10);
// sum of integers
IntegerParameter p3 = new IntegerParameter("1 2 5");
sum = new Sum();
sum.initByName("arg", p3);
v = sum.getArrayValue();
assertEquals(8.0, v, 1e-10);
// sum of boolean
BooleanParameter p4 = new BooleanParameter("true false false true true");
sum = new Sum();
sum.initByName("arg", p4);
v = sum.getArrayValue();
assertEquals(3.0, v, 1e-10);
// sum of booleans and integer
sum = new Sum();
sum.initByName("arg", p4, "arg", p3);
v = sum.getArrayValue();
assertEquals(11.0, v, 1e-10);
// sum of booleans and real
sum = new Sum();
sum.initByName("arg", p1, "arg", p4);
v = sum.getArrayValue();
assertEquals(6.0, v, 1e-10);
}
开发者ID:CompEvol,项目名称:beast2,代码行数:50,代码来源:SumTest.java
示例7: recalculateScaleFactor
import beast.core.parameter.BooleanParameter; //导入依赖的package包/类
private void recalculateScaleFactor() {
BooleanParameter indicators = indicatorParamInput.get();
RealParameter rates = rateParamInput.get();
calculateUnscaledBranchRates(m_tree.getRoot(), 1.0, indicators, rates);
double timeTotal = 0.0;
double branchTotal = 0.0;
for (int i = 0; i < m_tree.getNodeCount(); i++) {
Node node = m_tree.getNode(i);
if (!node.isRoot()) {
double branchInTime = node.getParent().getHeight() - node.getHeight();
double branchLength = branchInTime * unscaledBranchRates[node.getNr()];
timeTotal += branchInTime;
branchTotal += branchLength;
}
}
scaleFactor = timeTotal / branchTotal;
scaleFactor *= meanRate.getValue();
}
开发者ID:CompEvol,项目名称:beast2,代码行数:28,代码来源:RandomLocalClockModel.java
注:本文中的beast.core.parameter.BooleanParameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论