5 #ifndef BPP_NUMERIC_HMM_LOGSUMHMMLIKELIHOOD_H 6 #define BPP_NUMERIC_HMM_LOGSUMHMMLIKELIHOOD_H 9 #include "../AbstractParametrizable.h" 10 #include "../Matrix/Matrix.h" 11 #include "../NumTools.h" 91 std::shared_ptr<HmmStateAlphabet> hiddenAlphabet,
92 std::shared_ptr<HmmTransitionMatrix> transitionMatrix,
93 std::shared_ptr<HmmEmissionProbabilities> emissionProbabilities,
94 const std::string& prefix =
"");
101 emissionProbabilities_(),
102 logLikelihood_(lik.logLikelihood_),
103 partialLogLikelihoods_(lik.partialLogLikelihoods_),
104 logLik_(lik.logLik_),
105 dLogLikelihood_(lik.dLogLikelihood_),
106 partialDLogLikelihoods_(lik.partialDLogLikelihoods_),
107 d2LogLikelihood_(lik.d2LogLikelihood_),
108 partialD2LogLikelihoods_(lik.partialD2LogLikelihoods_),
109 backLogLikelihood_(lik.backLogLikelihood_),
110 backLogLikelihoodUpToDate_(lik.backLogLikelihoodUpToDate_),
111 breakPoints_(lik.breakPoints_),
112 nbStates_(lik.nbStates_),
113 nbSites_(lik.nbSites_)
115 hiddenAlphabet_ = std::shared_ptr<HmmStateAlphabet>(lik.
hiddenAlphabet_->clone());
116 transitionMatrix_ = std::shared_ptr<HmmTransitionMatrix>(lik.
transitionMatrix_->clone());
120 transitionMatrix_->setHmmStateAlphabet(hiddenAlphabet_);
121 emissionProbabilities_->setHmmStateAlphabet(hiddenAlphabet_);
127 AbstractParametrizable::operator=(lik);
129 hiddenAlphabet_ = std::shared_ptr<HmmStateAlphabet>(lik.
hiddenAlphabet_->clone());
130 transitionMatrix_ = std::shared_ptr<HmmTransitionMatrix>(lik.
transitionMatrix_->clone());
147 transitionMatrix_->setHmmStateAlphabet(hiddenAlphabet_);
148 emissionProbabilities_->setHmmStateAlphabet(hiddenAlphabet_);
178 breakPoints_ = breakPoints;
180 backLogLikelihoodUpToDate_ =
false;
202 void setNamespace(
const std::string& nameSpace)
override;
232 #endif // BPP_NUMERIC_HMM_LOGSUMHMMLIKELIHOOD_H
HmmTransitionMatrix & hmmTransitionMatrix() override
std::shared_ptr< HmmEmissionProbabilities > emissionProbabilities_
void setNamespace(const std::string &nameSpace) override
Set the namespace for the parameter names.
std::vector< double > partialDLogLikelihoods_
void computeBackward_() const
std::vector< double > logLikelihood_
The likelihood array.
std::shared_ptr< const HmmStateAlphabet > getHmmStateAlphabet() const override
A simple implementation of hidden Markov models recursion.
A partial implementation of the Parametrizable interface.
const HmmStateAlphabet & hmmStateAlphabet() const override
Interface for computing emission probabilities in a Hidden Markov Model.
double getD2LogLikelihoodForASite(size_t site) const override
std::vector< std::vector< double > > d2LogLikelihood_
std::shared_ptr< HmmTransitionMatrix > getHmmTransitionMatrix() override
void fireParameterChanged(const ParameterList &pl) override
Notify the class when one or several parameters have changed.
std::shared_ptr< HmmTransitionMatrix > transitionMatrix_
const HmmTransitionMatrix & hmmTransitionMatrix() const override
std::shared_ptr< HmmEmissionProbabilities > getHmmEmissionProbabilities() override
The parameter list object.
HmmStateAlphabet & hmmStateAlphabet() override
Vdouble getLikelihoodForEachSite() const override
Get the likelihood for each site.
void setParameters(const ParameterList &pl) override
Set the point where the function must be computed.
virtual ~LogsumHmmLikelihood()
std::shared_ptr< const HmmTransitionMatrix > getHmmTransitionMatrix() const override
void setParametersValues(const ParameterList ¶meters) override
Update the parameters from parameters.
const std::vector< size_t > & getBreakPoints() const override
Vdouble getHiddenStatesPosteriorProbabilitiesForASite(size_t site) const override
void computeD2Forward_() const
std::vector< std::vector< double > > backLogLikelihood_
backward logLikelihood
std::vector< double > partialLogLikelihoods_
std::vector< double > Vdouble
std::vector< double > partialD2LogLikelihoods_
void computeDLikelihood_() const override
void getHiddenStatesPosteriorProbabilities(std::vector< std::vector< double >> &probs, bool append=false) const override
partial impmementation of Hmm Likelihoods.
HmmEmissionProbabilities & hmmEmissionProbabilities() override
std::shared_ptr< HmmStateAlphabet > hiddenAlphabet_
The alphabet describing the hidden states.
double getLogLikelihood() const override
AbstractHmmLikelihood & operator=(const AbstractHmmLikelihood &adhlik)
std::shared_ptr< const HmmEmissionProbabilities > getHmmEmissionProbabilities() const override
bool backLogLikelihoodUpToDate_
void setBreakPoints(const std::vector< size_t > &breakPoints) override
std::shared_ptr< HmmStateAlphabet > getHmmStateAlphabet() override
double getLikelihoodForASite(size_t site) const override
Get the likelihood for a site, and its derivatives.
std::vector< std::vector< double > > dLogLikelihood_
The DLogLikelihood arrays.
LogsumHmmLikelihood & operator=(const LogsumHmmLikelihood &lik)
void computeD2Likelihood_() const override
std::vector< size_t > breakPoints_
LogsumHmmLikelihood(std::shared_ptr< HmmStateAlphabet > hiddenAlphabet, std::shared_ptr< HmmTransitionMatrix > transitionMatrix, std::shared_ptr< HmmEmissionProbabilities > emissionProbabilities, const std::string &prefix="")
Build a new LogsumHmmLikelihood object.
void computeDForward_() const
double getDLogLikelihoodForASite(size_t site) const override
Describe the transition probabilities between hidden states of a Hidden Markov Model.
LogsumHmmLikelihood * clone() const override
Create a copy of this object and send a pointer to it.
const HmmEmissionProbabilities & hmmEmissionProbabilities() const override
LogsumHmmLikelihood(const LogsumHmmLikelihood &lik)
double getValue() const override
Get the value of the function at the current point.