23 Vdouble rcProbs = rDist->getProbabilities();
27 for (
size_t i = 0; i < nSites; ++i)
30 postProb_i->resize(nClasses);
34 for (
size_t c = 0; c < nClasses; c++)
36 Vdouble* postProb_i_c = &(*postProb_i)[c];
37 postProb_i_c->resize(nStates);
38 double* rcProb = &rcProbs[c];
39 for (
size_t x = 0; x < nStates; x++)
41 (*postProb_i_c)[x] = (*larray_i)[x] * (*rcProb) / sumprobs;
52 for (
size_t i = 0; i < nSites; i++)
55 for (
size_t c = 0; c < nClasses; c++)
57 Vdouble* larray_i_c = &(*larray_i)[c];
58 for (
size_t s = 0; s < nStates; s++)
60 likelihoods[i] += (*larray_i_c)[s];
65 for (
size_t i = 0; i < nSites; i++)
68 postProb_i->resize(nClasses);
70 double likelihood = likelihoods[i];
71 for (
size_t c = 0; c < nClasses; c++)
73 Vdouble* postProb_i_c = &(*postProb_i)[c];
74 postProb_i_c->resize(nStates);
75 Vdouble* larray_i_c = &(*larray_i)[c];
76 for (
size_t x = 0; x < nStates; x++)
78 (*postProb_i_c)[x] = (*larray_i_c)[x] / likelihood;
95 for (
size_t i = 0; i < probs.size(); i++)
103 freqs[k] += probs[i][j][k] * w;
unsigned int getWeight(size_t pos) const
VVdouble & getLeafLikelihoods(int nodeId)
size_t getNumberOfDistinctSites() const
Interface for double-recursive (DR) implementation of the likelihood computation.
virtual void computeLikelihoodAtNode(int nodeId, VVVdouble &likelihoodArray) const =0
Compute the likelihood array at a given node.
virtual DRASDRTreeLikelihoodData & likelihoodData() override=0
virtual size_t getNumberOfClasses() const =0
Get the number of classes.
virtual std::shared_ptr< const DiscreteDistributionInterface > getRateDistribution() const =0
Get the rate distribution used for the computation.
virtual size_t getNumberOfStates() const =0
virtual const Tree & tree() const =0
Get the tree (topology and branch lengths).
virtual bool isLeaf(int nodeId) const =0
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< VVdouble > VVVdouble
std::vector< Vdouble > VVdouble