41 #include <Bpp/Numeric/VectorTools.h> 54 VVVdouble postProb(nSites);
57 Vdouble rcProbs = rDist->getProbabilities();
61 for(
size_t i = 0; i < nSites; i++)
63 VVdouble * postProb_i = & postProb[i];
64 postProb_i->resize(nClasses);
65 Vdouble * larray_i = & larray[i];
66 for(
size_t c = 0; c < nClasses; c++)
68 Vdouble * postProb_i_c = & (* postProb_i)[c];
69 postProb_i_c->resize(nStates);
70 double * rcProb = & rcProbs[c];
71 for(
size_t x = 0; x < nStates; x++)
73 (* postProb_i_c)[x] = (* larray_i)[x] * (* rcProb);
83 Vdouble likelihoods(nSites, 0);
84 for(
size_t i = 0; i < nSites; i++)
86 VVdouble * larray_i = & larray[i];
87 for(
size_t c = 0; c < nClasses; c++)
89 Vdouble * larray_i_c = & (* larray_i)[c];
90 for(
size_t s = 0; s < nStates; s++)
92 likelihoods[i] += (* larray_i_c)[s];
97 for(
size_t i = 0; i < nSites; i++)
99 VVdouble * postProb_i = & postProb[i];
100 postProb_i->resize(nClasses);
101 VVdouble * larray_i = & larray[i];
102 double likelihood = likelihoods[i];
103 for(
size_t c = 0; c < nClasses; c++)
105 Vdouble * postProb_i_c = & (* postProb_i)[c];
106 postProb_i_c->resize(nStates);
107 Vdouble * larray_i_c = & (* larray_i)[c];
108 for(
size_t x = 0; x < nStates; x++)
110 (* postProb_i_c)[x] = (* larray_i_c)[x] / likelihood;
127 for (
size_t i = 0; i < probs.size(); i++)
135 freqs[k] += probs[i][j][k] * w;
unsigned int getWeight(size_t pos) const
size_t getNumberOfDistinctSites() const
virtual size_t getNumberOfStates() const =0
virtual size_t getNumberOfClasses() const =0
Get the number of classes.
VVdouble & getLeafLikelihoods(int nodeId)
virtual bool isLeaf(int nodeId) const =0
virtual const Tree & getTree() const =0
Get the tree (topology and branch lengths).
virtual DRASDRTreeLikelihoodData * getLikelihoodData()=0
virtual const DiscreteDistribution * getRateDistribution() const =0
Get the rate distribution used for the computation.
virtual void computeLikelihoodAtNode(int nodeId, VVVdouble &likelihoodArray) const =0
Compute the likelihood array at a given node.
Interface for double-recursive (DR) implementation of the likelihood computation. ...