bpp-core3
3.0.0
|
Basal interface for Hidden Markov Models likelihood computation. More...
#include <Bpp/Numeric/Hmm/HmmLikelihood.h>
Public Member Functions | |
virtual HmmLikelihood * | clone () const =0 |
Create a copy of this object and send a pointer to it. More... | |
virtual const HmmStateAlphabet & | hmmStateAlphabet () const =0 |
virtual HmmStateAlphabet & | hmmStateAlphabet ()=0 |
virtual std::shared_ptr< const HmmStateAlphabet > | getHmmStateAlphabet () const =0 |
virtual std::shared_ptr< HmmStateAlphabet > | getHmmStateAlphabet ()=0 |
virtual const HmmTransitionMatrix & | hmmTransitionMatrix () const =0 |
virtual HmmTransitionMatrix & | hmmTransitionMatrix ()=0 |
virtual std::shared_ptr< const HmmTransitionMatrix > | getHmmTransitionMatrix () const =0 |
virtual std::shared_ptr< HmmTransitionMatrix > | getHmmTransitionMatrix ()=0 |
virtual const HmmEmissionProbabilities & | hmmEmissionProbabilities () const =0 |
virtual HmmEmissionProbabilities & | hmmEmissionProbabilities ()=0 |
virtual std::shared_ptr< const HmmEmissionProbabilities > | getHmmEmissionProbabilities () const =0 |
virtual std::shared_ptr< HmmEmissionProbabilities > | getHmmEmissionProbabilities ()=0 |
virtual void | getHiddenStatesPosteriorProbabilities (std::vector< std::vector< double >> &probs, bool append) const =0 |
virtual Vdouble | getHiddenStatesPosteriorProbabilitiesForASite (size_t site) const =0 |
virtual double | getLogLikelihood () const =0 |
virtual double | getDLogLikelihood () const =0 |
virtual double | getD2LogLikelihood () const =0 |
virtual double | getLikelihoodForASite (size_t site) const =0 |
Get the likelihood for a site, and its derivatives. More... | |
virtual double | getDLogLikelihoodForASite (size_t site) const =0 |
virtual double | getD2LogLikelihoodForASite (size_t site) const =0 |
virtual Vdouble | getLikelihoodForEachSite () const =0 |
Get the likelihood for each site. More... | |
virtual const std::vector< size_t > & | getBreakPoints () const =0 |
virtual void | setBreakPoints (const std::vector< size_t > &breakPoints)=0 |
virtual void | enableSecondOrderDerivatives (bool yn)=0 |
Tell if derivatives must be computed. More... | |
virtual bool | enableSecondOrderDerivatives () const =0 |
Tell if derivatives must be computed. More... | |
virtual double | getSecondOrderDerivative (const std::string &variable) const =0 |
Get the second order derivative of the function at the current point. More... | |
virtual double | getSecondOrderDerivative (const std::string &variable1, const std::string &variable2) const =0 |
Get the value of the cross derivative of the function according to a given set of parameters. More... | |
virtual double | d2f (const std::string &variable, const ParameterList ¶meters) |
Get the value of the second order derivative of the function according to a given set of parameters. More... | |
virtual double | d2f (const std::string &variable1, const std::string &variable2, const ParameterList ¶meters) |
Get the value of the cross derivative of the function according to a given set of parameters. More... | |
virtual void | enableFirstOrderDerivatives (bool yn)=0 |
Tell if derivatives must be computed. More... | |
virtual bool | enableFirstOrderDerivatives () const =0 |
Tell if derivatives must be computed. More... | |
virtual double | getFirstOrderDerivative (const std::string &variable) const =0 |
Get the derivative of the function at the current point. More... | |
virtual double | df (const std::string &variable, const ParameterList ¶meters) |
Get the value of the first derivative of the function according to a given set of parameters. More... | |
virtual void | setParameters (const ParameterList ¶meters)=0 |
Set the point where the function must be computed. More... | |
virtual double | getValue () const =0 |
Get the value of the function at the current point. More... | |
virtual double | f (const ParameterList ¶meters) |
Get the value of the function according to a given set of parameters. More... | |
virtual bool | hasParameter (const std::string &name) const =0 |
Tell if there is a parameter with specified name. More... | |
virtual const ParameterList & | getParameters () const =0 |
Get all parameters available. More... | |
virtual const Parameter & | parameter (const std::string &name) const =0 |
Get the parameter with specified name. More... | |
virtual double | getParameterValue (const std::string &name) const =0 |
Get the value for parameter of name 'name'. More... | |
virtual void | setAllParametersValues (const ParameterList ¶meters)=0 |
Set the parameters values to be equals to those of parameters. More... | |
virtual void | setParameterValue (const std::string &name, double value)=0 |
Set the value of parameter with name name to be equal to value. More... | |
virtual void | setParametersValues (const ParameterList ¶meters)=0 |
Update the parameters from parameters. More... | |
virtual bool | matchParametersValues (const ParameterList ¶meters)=0 |
Update the parameters from parameters. More... | |
virtual void | removeConstraint (const std::string &name)=0 |
Remove the constraint associated with one parameter, if any. More... | |
virtual void | setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint)=0 |
Set/Change the constraint associated with one parameter. More... | |
virtual size_t | getNumberOfParameters () const =0 |
Get the number of parameters. More... | |
virtual void | setNamespace (const std::string &prefix)=0 |
Set the namespace for the parameter names. More... | |
virtual std::string | getNamespace () const =0 |
virtual std::string | getParameterNameWithoutNamespace (const std::string &name) const =0 |
Resolves a parameter name according to the current namespace. More... | |
Protected Member Functions | |
virtual void | computeDLikelihood_ () const =0 |
virtual void | computeD2Likelihood_ () const =0 |
virtual ParameterList & | getParameters_ ()=0 |
Get all parameters available. More... | |
Basal interface for Hidden Markov Models likelihood computation.
HmmLikelihood classes compute the probability of data according to parameters (likelihood), using the so-called forward recursion:
The initial frequencies, set to the equilibrium frequencies of the chain.
where denotes the hidden states of the alphabet, the probability of the data at position i conditioned on hidden state y (emission probabilities) and is the probability of havving hidden state y at state i+1 knowing there is hidden state x at position i (transition probabilities). These essential elements are given respectively by the HmmEmissionProbabilities and HmmTransitionMatrix object associated to this class. Both objects have to share the same HmmStateAlphabet instance, which describes all allowed hidden states.
The HmmLikelihood interface provides essentially two major methods:
Definition at line 41 of file HmmLikelihood.h.
|
pure virtual |
Create a copy of this object and send a pointer to it.
Implements bpp::SecondOrderDerivable.
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
protectedpure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
Referenced by bpp::AbstractHmmLikelihood::getSecondOrderDerivative().
|
protectedpure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
Referenced by bpp::AbstractHmmLikelihood::getFirstOrderDerivative().
|
inlinevirtualinherited |
Get the value of the second order derivative of the function according to a given set of parameters.
variable | The name of the variable in . |
parameters | The parameter set to pass to the function. |
Exception | If an error occured. |
Definition at line 193 of file Functions.h.
References bpp::FunctionInterface::setParameters().
|
inlinevirtualinherited |
Get the value of the cross derivative of the function according to a given set of parameters.
variable1 | The name of the variable in . |
variable2 | The name of the variable in . |
parameters | The parameter set to pass to the function. |
Exception | If an error occured. |
Definition at line 220 of file Functions.h.
References bpp::FunctionInterface::setParameters().
|
inlinevirtualinherited |
Get the value of the first derivative of the function according to a given set of parameters.
variable | The name of the variable in . |
parameters | The parameter set to pass to the function. |
Exception | If an error occured. |
Definition at line 138 of file Functions.h.
References bpp::FunctionInterface::setParameters().
|
pure virtualinherited |
Tell if derivatives must be computed.
yn | yes/no |
Implemented in bpp::FirstOrderDerivableWrapper, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractHmmLikelihood.
Referenced by bpp::ConjugateGradientMultiDimensions::doInit(), bpp::BfgsMultiDimensions::doInit(), bpp::ConjugateGradientMultiDimensions::doStep(), and bpp::BfgsMultiDimensions::doStep().
|
pure virtualinherited |
Tell if derivatives must be computed.
Implemented in bpp::FirstOrderDerivableWrapper, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractHmmLikelihood.
|
pure virtualinherited |
Tell if derivatives must be computed.
yn | yes/no |
Implemented in bpp::SecondOrderDerivableWrapper, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractHmmLikelihood.
|
pure virtualinherited |
Tell if derivatives must be computed.
Implemented in bpp::SecondOrderDerivableWrapper, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractHmmLikelihood.
|
inlinevirtualinherited |
Get the value of the function according to a given set of parameters.
parameters | The parameter set to pass to the function. |
Exception | If an error occured. |
Reimplemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, and bpp::AbstractNumericalDerivative.
Definition at line 82 of file Functions.h.
References bpp::FunctionInterface::getValue(), and bpp::FunctionInterface::setParameters().
Referenced by bpp::NumTools::uniRoot().
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::AbstractHmmLikelihood.
|
pure virtual |
Implemented in bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, and bpp::RescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::AbstractHmmLikelihood.
|
pure virtual |
Implemented in bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, and bpp::RescaledHmmLikelihood.
|
pure virtualinherited |
Get the derivative of the function at the current point.
variable | The name of the variable in . |
Exception | If no point is specified or if an error occured. |
Implemented in bpp::FirstOrderDerivableWrapper, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractHmmLikelihood.
Referenced by bpp::NewtonOneDimension::doStep(), bpp::AbstractHmmLikelihood::enableFirstOrderDerivatives(), bpp::ConjugateGradientMultiDimensions::getGradient(), and bpp::BfgsMultiDimensions::getGradient().
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Get the likelihood for a site, and its derivatives.
site | The site index to analyse. |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Get the likelihood for each site.
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtualinherited |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Get the number of parameters.
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, bpp::AbstractParametrizable, and bpp::DirectionFunction.
Referenced by bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution(), and bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Resolves a parameter name according to the current namespace.
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Get all parameters available.
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, bpp::DirectionFunction, and bpp::AbstractParametrizable.
Referenced by bpp::ParameterAliasableAdapter::getIndependentParameters(), bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::Parametrizable::~Parametrizable().
|
protectedpure virtualinherited |
Get all parameters available.
Implemented in bpp::FunctionWrapper, bpp::AbstractParametrizable, and bpp::DirectionFunction.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Get the value for parameter of name 'name'.
name | The name of the parameter. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), and bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Get the second order derivative of the function at the current point.
variable | The name of the variable in . |
Exception | If no point is specified or if an error occured. |
Implemented in bpp::SecondOrderDerivableWrapper, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::AbstractNumericalDerivative, bpp::AbstractHmmLikelihood, and bpp::TwoPointsNumericalDerivative.
Referenced by bpp::NewtonOneDimension::doStep(), and bpp::AbstractHmmLikelihood::enableSecondOrderDerivatives().
|
pure virtualinherited |
Get the value of the cross derivative of the function according to a given set of parameters.
variable1 | The name of the variable in . |
variable2 | The name of the variable in . |
Exception | If an error occured. |
Implemented in bpp::SecondOrderDerivableWrapper, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::AbstractNumericalDerivative, bpp::AbstractHmmLikelihood, bpp::FivePointsNumericalDerivative, and bpp::TwoPointsNumericalDerivative.
|
pure virtualinherited |
Get the value of the function at the current point.
Exception | If no point is specified or if an error occured. |
Implemented in bpp::TestFunction, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::ReparametrizationFunctionWrapper, bpp::ThreePointsNumericalDerivative, bpp::FivePointsNumericalDerivative, bpp::TwoPointsNumericalDerivative, and bpp::DirectionFunction.
Referenced by bpp::FunctionInterface::f(), bpp::AbstractNumericalDerivative::f(), bpp::InfinityFunctionWrapper::f(), and bpp::FunctionInterface::~FunctionInterface().
|
pure virtualinherited |
Tell if there is a parameter with specified name.
name | The name of the parameter to look for. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtual |
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtualinherited |
Update the parameters from parameters.
Only common parameters with parameters will be updated.
parameters | A list of parameters. |
ConstraintException | If a value in parameters does not match the constraint in the corresponding parameter in the list. |
Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::TestFunction::setParameters(), and bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Get the parameter with specified name.
name | The name of the parameter to look for. |
ParameterNotFoundException | if no parameter with this name is found. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::TestFunction::getValue(), and bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Remove the constraint associated with one parameter, if any.
name | The name of the parameter to look for. |
ParameterNotFoundException | if no parameter with this name is found. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Set the parameters values to be equals to those of parameters.
The list must contain exactly the same parameters (ie same names) than the parameters available.
parameters | A list with all parameters. |
ParameterNotFoundException | If a some parameter in the list is not in params. |
ConstraintException | If a value in parameters does not match the constraint in the corresponding parameter in the list. |
Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtual |
Implemented in bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, and bpp::LowMemoryRescaledHmmLikelihood.
|
pure virtualinherited |
Set/Change the constraint associated with one parameter.
name | The name of the parameter to look for. |
constraint | A pointer to the constraint (may be null) |
ParameterNotFoundException | if no parameter with this name is found. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Set the namespace for the parameter names.
prefix | The 'namespace', that is a prefix to add to all parameter names. If parameter names are already prefixed, the new prefix will be used instead. |
Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, bpp::AbstractParametrizable, and bpp::InvariantMixedDiscreteDistribution.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Set the point where the function must be computed.
parameters | The parameter set to pass to the function. |
Implemented in bpp::TestFunction, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::ReparametrizationFunctionWrapper, and bpp::DirectionFunction.
Referenced by bpp::SecondOrderDerivable::d2f(), bpp::InfinityDerivableSecondOrderWrapper::d2f(), bpp::FirstOrderDerivable::df(), bpp::InfinityDerivableFirstOrderWrapper::df(), bpp::FunctionInterface::f(), bpp::AbstractNumericalDerivative::f(), bpp::InfinityFunctionWrapper::f(), and bpp::FunctionInterface::~FunctionInterface().
|
pure virtualinherited |
Update the parameters from parameters.
parameters must be a subset of all parameters available.
parameters | A list containing all parameters to update. |
ParameterNotFoundException | If a some parameter in params is not in the list. |
ConstraintException | If a value in parameters does not match the constraint in the corresponding parameter in the list. |
Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().
|
pure virtualinherited |
Set the value of parameter with name name to be equal to value.
name | the name of the parameter to set. |
value | The value of the parameter. |
ParameterNotFoundException | If no parameter in the list has the name name. |
ConstraintException | If value does not match the constraint associated to parameter name. |
Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.
Referenced by bpp::Parametrizable::~Parametrizable().