9 using namespace numeric;
14 auto rates = getLikelihoodCalculationSingleProcess()->substitutionProcess().getRateDistribution();
16 if (!rates || rates->getNumberOfCategories() == 1)
20 auto probas = rates->getProbabilities();
21 std::vector<DataLik> vv(rates->getNumberOfCategories());
22 for (
size_t i = 0; i < vv.size(); i++)
24 vv[i] = probas[i] * (getLikelihoodCalculationSingleProcess()->getSiteLikelihoodsForAClass(i))(Eigen::Index(pos));
28 Vdouble res(rates->getNumberOfCategories());
30 for (
size_t i = 0; i < vv.size(); i++)
40 auto rates = getLikelihoodCalculationSingleProcess()->substitutionProcess().getRateDistribution();
42 auto nbS = getLikelihoodCalculationSingleProcess()->getNumberOfSites();
45 if (!rates || rates->getNumberOfCategories() == 1)
54 Eigen::VectorXd probas;
57 auto vvLik = getLikelihoodCalculationSingleProcess()->getSiteLikelihoodsForAllClasses();
58 for (
size_t i = 0; i < nbS; i++)
60 vv[i].resize(
size_t(vvLik.rows()));
75 auto eg = getLikelihoodCalculationSingleProcess()->getSiteLikelihoodsForAllClasses();
84 size_t nbSites = getNumberOfSites();
85 auto l = getLikelihoodPerSitePerClass();
86 vector<size_t> classes(nbSites);
87 for (
size_t i = 0; i < nbSites; ++i)
89 classes[i] = VectorTools::whichMax<DataLik>(l[i]);
98 auto probas = getLikelihoodCalculationSingleProcess()->substitutionProcess().getRateDistribution()->getProbabilities();
99 auto rates = getLikelihoodCalculationSingleProcess()->substitutionProcess().getRateDistribution()->getCategories();
101 size_t nbSites = getNumberOfSites();
102 size_t nbClasses = getNumberOfClasses();
103 auto pb = getLikelihoodPerSitePerClass();
104 auto l = getLikelihoodPerSite();
106 for (
size_t i = 0; i < nbSites; i++)
108 for (
size_t j = 0; j < nbClasses; j++)
110 prates[i] +=
convert((pb[i][j] / l[i]) * probas[j] * rates[j]);
121 auto vv = getLikelihoodCalculationSingleProcess()->getLikelihoodsAtNode(nodeId)->targetValue();
123 size_t nbSites = getNumberOfSites();
127 for (uint i = 0; i < (uint)nbSites; i++)
133 for (uint st = 0; st < (uint)nbStates_; st++)
136 for (
size_t i = 0; i < (size_t)nbSites; i++)
138 s += pp[i][size_t(st)];
141 v[size_t(st)] = s / (double)nbSites;
const ExtendedFloat & sum() const
VVdouble getPosteriorProbabilitiesPerSitePerClass() const
Get the posterior probabilities of each class, for each site.
VVDataLik getLikelihoodPerSitePerClass() const
Vdouble getPosteriorProbabilitiesForSitePerClass(size_t pos) const
Vdouble getPosteriorStateFrequencies(uint nodeId)
std::vector< size_t > getClassWithMaxPostProbPerSite() const
Vdouble getPosteriorRatePerSite() const
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
template void copyEigenToBpp(const ExtendedFloatMatrixXd &eigenMatrix, std::vector< std::vector< double >> &bppMatrix)
template void copyBppToEigen(const std::vector< ExtendedFloat > &bppVector, Eigen::RowVectorXd &eigenVector)
std::vector< VDataLik > VVDataLik
double convert(const bpp::ExtendedFloat &ef)
std::vector< Vdouble > VVdouble