14void MultinomialFromTransitionModel::compute_Multinomial_(
const Eigen::VectorXd& counts)
const
18 for (
auto i = 0; i < Eigen::Index(
size_); i++)
20 double* Pi_i = &
Pi_(i);
21 for (
auto j = 0; j < Eigen::Index(
size_); j++)
25 *Pi_i += counts(j) *
std::log((*
Pij_t)(
size_t(i),
size_t(j)));
35 Pi_.array() = 0;
dPi_.array() = 0;
37 for (
size_t i = 0; i <
size_; i++)
39 double* Pi_i(&
Pi_(Eigen::Index(i))), *dPi_i(&
dPi_(Eigen::Index(i)));
41 for (
size_t j = 0; j <
size_; j++)
43 if (counts(Eigen::Index(j)) != 0)
46 *dPi_i += counts(Eigen::Index(j)) * (*dPij_dt)(i, j) / (*
Pij_t)(i, j);
58 for (
size_t i = 0; i <
size_; i++)
60 double* Pi_i(&
Pi_(Eigen::Index(i))), *d2Pi_i(&
d2Pi_(Eigen::Index(i)));
62 for (
size_t j = 0; j <
size_; j++)
64 if (counts(Eigen::Index(j)) != 0)
67 *d2Pi_i += counts(Eigen::Index(j)) * (*d2Pij_dt2)(i, j) / (*
Pij_t)(i, j);
const Matrix< double > * dPij_dt
Eigen::VectorXd Pi_
Used return vectors.
const Eigen::VectorXd & d2Lik_dt2(const Eigen::VectorXd &from, double t) const override
TransitionModelInterface & transitionModel()
const Matrix< double > * d2Pij_dt2
double getFact_(const Eigen::VectorXd &counts) const
Compute the log of the normalization term for the multinomial for any count, and keeps it in a map to...
const Eigen::VectorXd & Lik_t(const Eigen::VectorXd &from, double t) const override
void compute_Multinomial_(const Eigen::VectorXd &counts) const
Fills the res vector of the likelihoods of the counts given ancestral states & transition matrix.
const Matrix< double > * Pij_t
Transition Matrices owned by the submodel.
double tref_
Reference time to avoid recomuputation of transition matrix when time has not changed....
const Eigen::VectorXd & dLik_dt(const Eigen::VectorXd &from, double t) const override
void compute_d2Multinomial_dt2_(const Eigen::VectorXd &counts) const
void compute_dMultinomial_dt_(const Eigen::VectorXd &counts) const
virtual const Matrix< double > & getPij_t(double t) const =0
virtual const Matrix< double > & getdPij_dt(double t) const =0
virtual const Matrix< double > & getd2Pij_dt2(double t) const =0
T to(const std::string &s)
Defines the basic types of data flow nodes.
ExtendedFloat exp(const ExtendedFloat &ef)