本文整理汇总了C++中TopologyNode::getBranchLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TopologyNode::getBranchLength方法的具体用法?C++ TopologyNode::getBranchLength怎么用?C++ TopologyNode::getBranchLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopologyNode
的用法示例。
在下文中一共展示了TopologyNode::getBranchLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recursiveLnProb
double BrownianPhyloProcess::recursiveLnProb( const TopologyNode& from ) {
double lnProb = 0.0;
size_t index = from.getIndex();
double val = (*value)[index];
if (! from.isRoot()) {
// x ~ normal(x_up, sigma^2 * branchLength)
size_t upindex = from.getParent().getIndex();
double standDev = sigma->getValue() * sqrt(from.getBranchLength());
double mean = (*value)[upindex] + drift->getValue() * from.getBranchLength();
lnProb += RbStatistics::Normal::lnPdf(val, standDev, mean);
}
// propagate forward
size_t numChildren = from.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i) {
lnProb += recursiveLnProb(from.getChild(i));
}
return lnProb;
}
示例2: recursiveSimulate
void BrownianPhyloProcess::recursiveSimulate(const TopologyNode& from) {
size_t index = from.getIndex();
if (! from.isRoot()) {
// x ~ normal(x_up, sigma^2 * branchLength)
size_t upindex = from.getParent().getIndex();
double standDev = sigma->getValue() * sqrt(from.getBranchLength());
double mean = (*value)[upindex] + drift->getValue() * from.getBranchLength();
// simulate the new Val
RandomNumberGenerator* rng = GLOBAL_RNG;
(*value)[index] = RbStatistics::Normal::rv( mean, standDev, *rng);
}
// propagate forward
size_t numChildren = from.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i) {
recursiveSimulate(from.getChild(i));
}
}
示例3: recursiveSimulate
void PhyloWhiteNoiseProcess::recursiveSimulate(const TopologyNode& from)
{
if (! from.isRoot())
{
// get the index
size_t index = from.getIndex();
// compute the variance along the branch
double mean = 1.0;
double stdev = sigma->getValue() / sqrt(from.getBranchLength());
double alpha = mean * mean / (stdev * stdev);
double beta = mean / (stdev * stdev);
// simulate a new Val
RandomNumberGenerator* rng = GLOBAL_RNG;
double v = RbStatistics::Gamma::rv( alpha,beta, *rng);
// we store this val here
(*value)[index] = v;
}
// simulate the val for each child (if any)
size_t numChildren = from.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i)
{
const TopologyNode& child = from.getChild(i);
recursiveSimulate(child);
}
}
示例4: recursiveSimulate
void AutocorrelatedLognormalRateBranchwiseVarDistribution::recursiveSimulate(const TopologyNode& node, double parentRate) {
// get the index
size_t nodeIndex = node.getIndex();
// compute the variance along the branch
double scale = scaleValue->getValue();
double variance = sigma->getValue()[nodeIndex] * node.getBranchLength() * scale;
double mu = log(parentRate) - (variance * 0.5);
double stDev = sqrt(variance);
// simulate a new rate
RandomNumberGenerator* rng = GLOBAL_RNG;
double nodeRate = RbStatistics::Lognormal::rv( mu, stDev, *rng );
// we store this rate here
(*value)[nodeIndex] = nodeRate;
// simulate the rate for each child (if any)
size_t numChildren = node.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i) {
const TopologyNode& child = node.getChild(i);
recursiveSimulate(child,nodeRate);
}
}
示例5: recursiveLnProb
double MultivariateBrownianPhyloProcess::recursiveLnProb( const TopologyNode& from ) {
double lnProb = 0.0;
size_t index = from.getIndex();
std::vector<double> val = (*value)[index];
if (! from.isRoot()) {
if (1) {
// if (dirtyNodes[index]) {
// x ~ normal(x_up, sigma^2 * branchLength)
size_t upindex = from.getParent().getIndex();
std::vector<double> upval = (*value)[upindex];
const MatrixReal& om = sigma->getValue().getInverse();
double s2 = 0;
for (size_t i = 0; i < getDim(); i++) {
double tmp = 0;
for (size_t j = 0; j < getDim(); j++) {
tmp += om[i][j] * (val[j] - upval[j]);
}
s2 += (val[i] - upval[i]) * tmp;
}
double logprob = 0;
logprob -= 0.5 * s2 / from.getBranchLength();
logprob -= 0.5 * (sigma->getValue().getLogDet() + sigma->getValue().getDim() * log(from.getBranchLength()));
nodeLogProbs[index] = logprob;
dirtyNodes[index] = false;
}
lnProb += nodeLogProbs[index];
}
// propagate forward
size_t numChildren = from.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i) {
lnProb += recursiveLnProb(from.getChild(i));
}
return lnProb;
}
示例6: calculateTransitionProbabilities
void RateMap_Biogeography::calculateTransitionProbabilities(const TopologyNode& node, TransitionProbabilityMatrix &P) const
{
double branchLength = node.getBranchLength();
double r = ( branchHeterogeneousClockRates ? heterogeneousClockRates[node.getIndex()] : homogeneousClockRate );
const std::vector<double>& glr = ( branchHeterogeneousGainLossRates ? heterogeneousGainLossRates[node.getIndex()] : homogeneousGainLossRates );
if (node.isRoot())
branchLength = 1e10;
double expPart = exp( -(glr[0] + glr[1]) * r * branchLength);
double p = glr[0] / (glr[0] + glr[1]);
double q = 1.0 - p;
P[0][0] = p + q * expPart;
P[0][1] = q - q * expPart;
P[1][0] = p - p * expPart;
P[1][1] = q + p * expPart;
}
示例7: recursiveLnProb
double PhyloWhiteNoiseProcess::recursiveLnProb(const TopologyNode &from) {
double lnProb = 0.0;
if (! from.isRoot()) {
// compute the variance
double mean = 1.0;
double stdev = sigma->getValue() / sqrt(from.getBranchLength());
double alpha = mean * mean / (stdev * stdev);
double beta = mean / (stdev * stdev);
double v = (*value)[from.getIndex()];
lnProb += log( RbStatistics::Gamma::lnPdf(alpha,beta,v) );
}
size_t numChildren = from.getNumberOfChildren();
for (size_t i = 0; i < numChildren; ++i) {
const TopologyNode& child = from.getChild(i);
lnProb += recursiveLnProb(child);
}
return lnProb;
}