本文整理汇总了Java中beast.core.parameter.RealParameter.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java RealParameter.getValue方法的具体用法?Java RealParameter.getValue怎么用?Java RealParameter.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.core.parameter.RealParameter
的用法示例。
在下文中一共展示了RealParameter.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: branchLogP
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public double branchLogP(int speciesTreeNodeNumber, Node speciesTreeNode, double ploidy, double[] branchCoalescentTimes, int branchLineageCount, int branchEventCount) {
final RealParameter tipPopSizes = tipPopSizesInput.get();
final RealParameter topPopSizes = topPopSizesInput.get();
double branchTipPopSize;
if (speciesTreeNode.isLeaf()) {
branchTipPopSize = tipPopSizes.getValue(speciesTreeNodeNumber);
} else {
final int leftChildTopI = speciesTreeNode.getLeft().getNr();
final int rightChildTopI = speciesTreeNode.getRight().getNr();
branchTipPopSize = topPopSizes.getValue(leftChildTopI) + topPopSizes.getValue(rightChildTopI);
}
if (speciesTreeNode.isRoot()) {
return ConstantPopulations.constantLogP(branchTipPopSize, ploidy, branchCoalescentTimes, branchLineageCount, branchEventCount);
} else {
final int speciesTopI = speciesTreeNodeNumber;
final double branchTopPopSize = topPopSizes.getValue(speciesTopI);
return linearLogP(branchTopPopSize, branchTipPopSize, ploidy, branchCoalescentTimes, branchLineageCount, branchEventCount);
}
}
示例2: serialize
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void serialize(Node speciesTreeNode, StringBuffer buf, DecimalFormat df) {
final RealParameter tipPopSizes = tipPopSizesInput.get();
final RealParameter topPopSizes = topPopSizesInput.get();
final int speciesTreeNodeNumber = speciesTreeNode.getNr();
double branchTipPopSize;
if (speciesTreeNode.isLeaf()) {
branchTipPopSize = tipPopSizes.getValue(speciesTreeNodeNumber);
} else {
final int leftChildTopI = speciesTreeNode.getLeft().getNr();
final int rightChildTopI = speciesTreeNode.getRight().getNr();
branchTipPopSize = topPopSizes.getValue(leftChildTopI) + topPopSizes.getValue(rightChildTopI);
}
final double branchTopPopSize = (speciesTreeNode.isRoot()) ? branchTipPopSize : topPopSizes.getValue(speciesTreeNode.getNr());
if (df == null) buf.append("dmv={" + branchTopPopSize + "," + branchTipPopSize + "}");
else buf.append("dmv={" + df.format(branchTopPopSize) + "," + df.format(branchTipPopSize) + "}");
}
示例3: update
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
private void update() {
final Boolean[] indicators = indicatorsInput.get().getValues();
final Double[] rates = branchRatesInput.get().getValues();
final Node treeRoot = treeInput.get().getRoot();
final double treeHeight = treeRoot.getHeight();
double estimatedMean;
final RealParameter estimatedMeanParameter = meanRateInput.get();
if (estimatedMeanParameter == null) {
estimatedMean = 1.0;
} else {
estimatedMean = estimatedMeanParameter.getValue();
}
ratesArray[rootNodeNumber] = estimatedMean;
strictRatesTotal = 0.0;
relaxedRatesTotal = 0.0;
recurseBranchRates(treeRoot, treeHeight, 1.0, indicators, rates);
// normalize the weighted average of branch rates to equal the mean rate parameter
double scaleFactor = estimatedMean * strictRatesTotal / relaxedRatesTotal;
for (int i = 0; i < rootNodeNumber; i++) {
ratesArray[i] = ratesArray[i] * scaleFactor;
}
}
示例4: calculateUnscaledBranchRates
import beast.core.parameter.RealParameter; //导入方法依赖的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);
}
}
示例5: initAndValidate
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void initAndValidate(){
df = dfInput.get();
RealParameter scaleMatrix1d = scaleMatrixInput.get();
dim = (int)Math.sqrt(scaleMatrix1d.getDimension());
scaleMatrix = new double[dim][dim];
int k = 0;
for(int i = 0; i < dim;i++){
for(int j = 0; j < dim; j++){
scaleMatrix[i][j] = scaleMatrix1d.getValue(k++);
//System.out.print(scaleMatrix[i][j]+" ");
}
//System.out.println();
}
refresh();
}
示例6: proposal
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
* override this for proposals,
* returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
*/
@Override
public double proposal() {
RealParameter param = parameterInput.get(this);
int i = Randomizer.nextInt(param.getDimension());
double value = param.getValue(i);
double newValue = getProposedVal(
value, //original value
i, //index of the value
useGaussian, //whether to use gaussian moves
windowSizes); //window sizes
if (newValue < param.getLower() || newValue > param.getUpper()) {
return Double.NEGATIVE_INFINITY;
}
if (newValue == value) {
// this saves calculating the posterior
return Double.NEGATIVE_INFINITY;
}
param.setValue(i, newValue);
lastChangedValueIndex = i;
return 0.0;
}
示例7: proposal
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public double proposal() {
RealParameter param = parameterInput.get(this);
double value = param.getValue(index);
double newValue = value;
if (useGaussian) {
newValue += Randomizer.nextGaussian() * windowSize;
} else {
newValue += Randomizer.nextDouble() * 2 * windowSize - windowSize;
}
if (newValue < param.getLower() || newValue > param.getUpper()) {
return Double.NEGATIVE_INFINITY;
}
if (newValue == value) {
// this saves calculating the posterior
return Double.NEGATIVE_INFINITY;
}
param.setValue(index, newValue);
return 0.0;
}
示例8: initAndValidate
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void initAndValidate(){
df = dfInput.get();
RealParameter scaleMatrixParam = scaleMatrixInput.get();
dim = (int)(Math.sqrt(scaleMatrixParam.getDimension()));
scaleMatrixInv = new double[dim][dim];
int k = 0;
for(int i = 0; i < dim; i++){
for(int j = 0; j < dim; j++){
scaleMatrixInv[i][j] = scaleMatrixParam.getValue(k++);
}
}
scaleMatrixInv = (new Matrix(scaleMatrixInv)).inverse().toComponents();
mean = meanInput.get();
x = xInput.get();
}
示例9: proposal
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public double proposal() {
Tree tree = treeInput.get();
final RealParameter rParameter = rInput.get(this);
double r = rParameter.getValue();
if (r != 1 && ((ZeroBranchSATree)tree).getDirectAncestorNodeCount() == 0) {
rParameter.setValue(1.);
return 0.0;
} else if (r == 1) {
rParameter.setValue(Randomizer.nextDouble());
return 0.0;
} else return Double.NEGATIVE_INFINITY;
}
示例10: proposal
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
* override this for proposals,
* returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
*/
@Override
public double proposal() {
RealParameter param = parameterInput.get(this);
for (int i = 0; i < param.getDimension(); i++){
double value = param.getValue(i);
double newValue = value;
double windowSize = 0.0;
if (indicatorInput.get().getArrayValue(i) > 0.5)
windowSize = windowSizeOn;
else
windowSize = windowSizeOff;
if (useGaussian) {
newValue += Randomizer.nextGaussian() * windowSize;
} else {
newValue += Randomizer.nextDouble() * 2 * windowSize - windowSize;
}
if (newValue < param.getLower() || newValue > param.getUpper()) {
return Double.NEGATIVE_INFINITY;
}
if (newValue == value) {
// this saves calculating the posterior
return Double.NEGATIVE_INFINITY;
}
param.setValue(i, newValue);
}
return 0.0;
}
示例11: update
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
private void update() {
if (useLogNormal && (binRatesNeedsUpdate || noCache)) {
// set the mean in real space to equal 1
currentLogNormalStdev = stdevInput.get().getValue();
final double newMean = -(0.5 * currentLogNormalStdev * currentLogNormalStdev);
final NormalDistribution normalDistr = new NormalDistributionImpl(newMean, currentLogNormalStdev);
try {
for (int i = 0; i < nBins; i++) {
binRates[i] = Math.exp(normalDistr.inverseCumulativeProbability((i + 0.5) / nBins));
}
} catch (MathException e) {
throw new RuntimeException("Failed to compute inverse cumulative probability!");
}
}
Double estimatedMean;
final RealParameter estimatedMeanParameter = meanRateInput.get();
if (estimatedMeanParameter == null) {
estimatedMean = 1.0;
} else {
estimatedMean = estimatedMeanParameter.getValue();
}
final Integer[] branchRatePointers = branchRatesInput.get().getValues();
for (int i = 0; i < nEstimatedRates; i++) {
int b = branchRatePointers[i];
ratesArray[i] = binRates[b] * estimatedMean;
}
if (!estimateRoot) ratesArray[rootNodeNumber] = estimatedMean;
/* StringBuffer x = new StringBuffer();
x.append(treeInput.get().getID());
for (int i = 0; i < ratesArray.length; i++) {
x.append(" ");
x.append(ratesArray[i]);
}
System.out.println(x); */
}
示例12: branchLogP
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public double branchLogP(int speciesTreeNodeNumber, Node speciesTreeNode, double ploidy, double[] branchCoalescentTimes, int branchLineageCount, int branchEventCount) {
final RealParameter popSizes = popSizesInput.get();
final double popSize = popSizes.getValue(speciesTreeNodeNumber);
double logP = constantLogP(popSize, ploidy, branchCoalescentTimes, branchLineageCount, branchEventCount);
return logP;
}
示例13: serialize
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void serialize(Node speciesTreeNode, StringBuffer buf, DecimalFormat df) {
final RealParameter popSizes = popSizesInput.get();
final int speciesTreeNodeNumber = speciesTreeNode.getNr();
final double branchPopSize = popSizes.getValue(speciesTreeNodeNumber);
buf.append("dmv={");
if (df == null) {
buf.append(branchPopSize);
} else {
buf.append(df.format(branchPopSize));
}
buf.append("}");
}
示例14: randomInit
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
private void randomInit(final SpeciesTree speciesTree, List<MRCAPrior> calibrations) {
final RealParameter birthRateParameter = birthRate.get();
final Double lambda = (birthRateParameter == null) ? 1.0 : birthRateParameter.getValue();
final Double initialPopSize = 1.0 / lambda; // scales coalescent tree height inverse to birth rate
final RealParameter popSize = new RealParameter(initialPopSize.toString());
final ConstantPopulation pf = new ConstantPopulation();
pf.setInputValue("popSize", popSize);
final RandomTree rnd = new RandomTree();
rnd.setInputValue("taxonset", speciesTree.getTaxonset());
if (speciesTree.hasDateTrait()) rnd.setInputValue("trait", speciesTree.getDateTrait());
for (final MRCAPrior cal: calibrations) rnd.setInputValue("constraint", cal);
rnd.setInputValue("populationModel", pf);
rnd.setInputValue("populationModel", pf);
rnd.initAndValidate();
speciesTree.assignFromWithoutID(rnd);
// System.out.println("BEFORE = " + speciesTree.toString());
/*final TraitSet speciesTipDates = speciesTree.getDateTrait();
if (speciesTree.hasDateTrait()) {
for (Node node: speciesTree.getNodesAsArray()) {
if (node.isLeaf()) {
final String taxonName = node.getID();
final double taxonHeight = speciesTipDates.getValue(taxonName);
node.setHeight(taxonHeight);
}
}
System.out.println("AFTER = " + speciesTree.toString());
}*/
}
示例15: proposal
import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
* override this for proposals,
* returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
*/
@Override
public double proposal() {
RealParameter param = parameterInput.get(this);
int i = Randomizer.nextInt(param.getDimension());
double value = param.getValue(i);
double newValue = value;
if (useGaussian) {
newValue += Randomizer.nextGaussian() * windowSize;
} else {
newValue += Randomizer.nextDouble() * 2 * windowSize - windowSize;
}
if (newValue < param.getLower() || newValue > param.getUpper()) {
return Double.NEGATIVE_INFINITY;
}
if (newValue == value) {
// this saves calculating the posterior
return Double.NEGATIVE_INFINITY;
}
param.setValue(i, newValue);
return 0.0;
}