本文整理汇总了Java中beast.core.parameter.RealParameter类的典型用法代码示例。如果您正苦于以下问题:Java RealParameter类的具体用法?Java RealParameter怎么用?Java RealParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealParameter类属于beast.core.parameter包,在下文中一共展示了RealParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateLogP
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Override
public double calculateLogP() {
Double[] mig = GLMStepwiseModelInput.get().getAllCoalescentRate();
Double[] coal = GLMStepwiseModelInput.get().getAllBackwardsMigration();
RealParameter dCoal = new RealParameter(coal);
RealParameter dMig = new RealParameter(mig);
logP = 0.0;
if (migrationOnlyInput.get()){
logP += dist.calcLogP(dMig);
}else{
logP += dist.calcLogP(dCoal);
logP += dist.calcLogP(dMig);
}
if (logP == Double.POSITIVE_INFINITY) {
logP = Double.NEGATIVE_INFINITY;
}
return logP;
}
示例2: testCSM
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Test
public void testCSM() throws Exception {
CSMwithPublicMatrix csm = new CSMwithPublicMatrix();
csm.initByName("rates", new RealParameter(rates), "frequencies", freqs, "shape", new IntegerParameter(shape));
final double[][] result = csm.getMatrix();
System.out.printf("%s\n", Arrays.deepToString(result));
System.out.printf("%s\n\n", Arrays.toString(expectedResult));
int i = 0;
for (int k = 0; k < result.length; ++k) {
for (int l = 0; l < result[k].length; ++l) {
assertEquals(expectedResult[i], result[k][l], 1e-10);
++i;
}
}
assertEquals(i, expectedResult.length);
}
示例3: randomTreeTest
import beast.core.parameter.RealParameter; //导入依赖的package包/类
private static void randomTreeTest() throws Exception {
StringBuilder traitSB = new StringBuilder();
List<Sequence> seqList = new ArrayList<Sequence>();
for (int i = 0; i < 10; i++) {
String taxonID = "t " + i;
seqList.add(new Sequence(taxonID, "?"));
if (i > 0)
traitSB.append(",");
traitSB.append(taxonID).append("=").append(i);
}
Alignment alignment = new Alignment(seqList, "nucleotide");
ConstantPopulation popFunc = new ConstantPopulation();
popFunc.initByName("popSize", new RealParameter("1.0"));
RandomTree t = new RandomTree();
t.initByName("taxa", alignment, "populationModel", popFunc);
Sequence l = new Sequence("", "");
System.out.println("Tree GTR Borrowing Test");
Tree tree = randomYuleTree(2, 0.01);
tree.getRoot().setMetaData("lang", l);
System.out.println(TreeUtils.getTreeLength(tree, tree.getRoot()));
}
示例4: 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);
}
}
示例5: initPopSizes
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Override
public void initPopSizes(double tipInitial) {
final double topInitial = tipInitial * 0.5;
final RealParameter tipPopSizes = tipPopSizesInput.get();
final RealParameter topPopSizes = topPopSizesInput.get();
final double tipLower = tipPopSizes.getLower();
final double tipUpper = tipPopSizes.getUpper();
final double topLower = topPopSizes.getLower();
final double topUpper = topPopSizes.getUpper();
if (tipPopSizes.isEstimatedInput.get() && tipInitial > tipLower && tipInitial < tipUpper) {
for (int i = 0; i < tipPopSizes.getDimension(); i++)
tipPopSizes.setValue(i, tipInitial);
}
if (topPopSizes.isEstimatedInput.get() && topInitial > topLower && topInitial < topUpper) {
for (int i = 0; i < topPopSizes.getDimension(); i++)
topPopSizes.setValue(i, topInitial);
}
}
示例6: 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) + "}");
}
示例7: initAndValidate
import beast.core.parameter.RealParameter; //导入依赖的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;
}
示例8: 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;
}
}
示例9: proposal
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Override
public double proposal() {
final RealParameter parameter = parameterInput.get();
final Double[] parameterArray = parameter.getValues();
final int[] cycle = chooseK(nNodes);
final int lastNodeNumber = cycle[discreteK - 1];
double previousRate = parameterArray[lastNodeNumber];
for (int i = 0; i < discreteK; i++) {
final int nodeNumber = cycle[i];
parameter.setValue(nodeNumber, previousRate);
previousRate = parameterArray[nodeNumber];
}
return 0.0;
}
示例10: MissingDataConstantIO
import beast.core.parameter.RealParameter; //导入依赖的package包/类
public MissingDataConstantIO() throws Exception {
ploidy = 2.0;
nSpecies = 4;
expectedLogP = -10.956285249389675; // haven't checked this is the right answer
state = new State();
alphaParameter = new RealParameter();
meanParameter = new RealParameter();
alphaParameter.initByName("value", String.valueOf(alpha));
meanParameter.initByName("value", String.valueOf(mean));
newickSpeciesTree = "((s0:0.32057156677143211,s3:0.32057156677143211):1.2653250035015629,(s1:0.56540722294658641,s2:0.56540722294658641):1.0204893473264085)";
newickGeneTrees.add("((((s0_tip1:0.3416660303037105,s3_tip0:0.3416660303037105):0.024561190897159135,s0_tip0:0.36622722120086965):0.0643095990846464,s3_tip1:0.43053682028551604):1.4201019862262891,(s2_tip0:0.19897724687831703,s2_tip1:0.19897724687831703):1.651661559633488)");
newickGeneTrees.add("((s3_tip0:0.09482581277282173,s3_tip1:0.09482581277282173):1.6017973588278296,((s1_tip0:0.33170960882423645,s1_tip1:0.33170960882423645):0.29497523293318856,(s2_tip0:0.2908611340994834,s2_tip1:0.2908611340994834):0.3358237076579416):1.0699383298432266)");
}
示例11: ConstantIOTest
import beast.core.parameter.RealParameter; //导入依赖的package包/类
public ConstantIOTest() throws Exception {
ploidy = 2.0;
nSpecies = 4;
expectedLogP = -14.5233984762; // this should be the right answer (calculated by hand)
state = new State();
alphaParameter = new RealParameter();
meanParameter = new RealParameter();
alphaParameter.initByName("value", String.valueOf(alpha));
meanParameter.initByName("value", String.valueOf(mean));
newickSpeciesTree = "((s0:0.32057156677143211,s3:0.32057156677143211):1.2653250035015629,(s1:0.56540722294658641,s2:0.56540722294658641):1.0204893473264085)";
newickGeneTrees.add("((((s0_tip1:0.3416660303037105,s3_tip0:0.3416660303037105):0.024561190897159135,s0_tip0:0.36622722120086965):0.0643095990846464,s3_tip1:0.43053682028551604):1.4201019862262891,((s1_tip0:0.14473698225381706,s1_tip1:0.14473698225381706):0.5135479407233198,(s2_tip0:0.19897724687831703,s2_tip1:0.19897724687831703):0.4593076760988198):1.1923538835346683)");
newickGeneTrees.add("(((s0_tip0:0.04173231934154758,s0_tip1:0.04173231934154758):0.7845256741090114,(s3_tip0:0.09482581277282173,s3_tip1:0.09482581277282173):0.7314321806777372):0.8703651781500925,((s1_tip0:0.33170960882423645,s1_tip1:0.33170960882423645):0.29497523293318856,(s2_tip0:0.2908611340994834,s2_tip1:0.2908611340994834):0.3358237076579416):1.0699383298432266)");
}
示例12: testRates
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Test
public void testRates() throws Exception {
initializeTree();
meanRateParameter = new RealParameter();
stdevParameter = new RealParameter();
branchRatesParameter = new IntegerParameter();
meanRateParameter.initByName("value", String.valueOf(meanRate));
stdevParameter.initByName("value", String.valueOf(1.0));
branchRatesParameter.initByName("value", String.valueOf(initialBranchRate));
// Create dummy state to allow statenode editing
State state = new State();
state.initByName("stateNode", meanRateParameter);
state.initByName("stateNode", branchRatesParameter);
state.initialise();
clockModel = new UncorrelatedRates();
clockModel.initByName("tree", testTree, "rates", branchRatesParameter, "stdev", stdevParameter, "estimateRoot", false, "clock.rate", meanRateParameter);
initializeRates();
checkRates();
}
示例13: main
import beast.core.parameter.RealParameter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
JFrame frame = new JFrame();
Map<String, Object> scope = new HashMap<>();
scope.put("x", new Double(3));
scope.put("y", new Double(4.3));
scope.put("z", new Double[]{1.0,2.0,3.0});
scope.put("A", new ArrayList<Double>());
scope.put("B", "AAAAAA");
scope.put("C", new RealParameter("3.14"));
VariableModel treeTableModel = new VariableModel(scope);
JTreeTable treetable = new JTreeTable(treeTableModel);
frame.add(treetable);
frame.setSize(1024,768);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
示例14: 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);
}
}
示例15: initAndValidate
import beast.core.parameter.RealParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
parameter = parameterInput.get();
if (parameter instanceof RealParameter) {
lower = (Double) parameter.getLower();
upper = (Double) parameter.getUpper();
} else if (parameter instanceof IntegerParameter) {
lowerIndex = (Integer) parameter.getLower();
upperIndex = (Integer) parameter.getUpper();
} else {
throw new IllegalArgumentException("parameter should be a RealParameter or IntergerParameter, not " + parameter.getClass().getName());
}
howMany = howManyInput.get();
if (howMany > parameter.getDimension()) {
throw new IllegalArgumentException("howMany it too large: must be less than the dimension of the parameter");
}
}