bpp-core3  3.0.0
bpp::AbstractHmmLikelihood Class Referenceabstract

#include <Bpp/Numeric/Hmm/HmmLikelihood.h>

+ Inheritance diagram for bpp::AbstractHmmLikelihood:
+ Collaboration diagram for bpp::AbstractHmmLikelihood:

Public Member Functions

 AbstractHmmLikelihood ()
 
 AbstractHmmLikelihood (const AbstractHmmLikelihood &adhlik)
 
AbstractHmmLikelihoodoperator= (const AbstractHmmLikelihood &adhlik)
 
void enableFirstOrderDerivatives (bool yn)
 Tell if derivatives must be computed. More...
 
bool enableFirstOrderDerivatives () const
 Tell if derivatives must be computed. More...
 
double getFirstOrderDerivative (const std::string &variable) const
 Get the derivative of the function at the current point. More...
 
double getDLogLikelihood () const
 
void enableSecondOrderDerivatives (bool yn)
 Tell if derivatives must be computed. More...
 
bool enableSecondOrderDerivatives () const
 Tell if derivatives must be computed. More...
 
double getSecondOrderDerivative (const std::string &variable) const
 Get the second order derivative of the function at the current point. More...
 
double getD2LogLikelihood () const
 
double getSecondOrderDerivative (const std::string &variable1, const std::string &variable2) const
 Get the value of the cross derivative of the function according to a given set of parameters. More...
 
virtual HmmLikelihoodclone () const =0
 Create a copy of this object and send a pointer to it. More...
 
virtual const HmmStateAlphabetgetHmmStateAlphabet () const =0
 
virtual HmmStateAlphabetgetHmmStateAlphabet ()=0
 
virtual const HmmTransitionMatrixgetHmmTransitionMatrix () const =0
 
virtual HmmTransitionMatrixgetHmmTransitionMatrix ()=0
 
virtual const HmmEmissionProbabilitiesgetHmmEmissionProbabilities () const =0
 
virtual HmmEmissionProbabilitiesgetHmmEmissionProbabilities ()=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 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 double d2f (const std::string &variable, const ParameterList &parameters)
 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 &parameters)
 Get the value of the cross derivative of the function according to a given set of parameters. More...
 
virtual double df (const std::string &variable, const ParameterList &parameters)
 Get the value of the first derivative of the function according to a given set of parameters. More...
 
virtual void setParameters (const ParameterList &parameters)=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 &parameters)
 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 ParameterListgetParameters () const =0
 Get all parameters available. More...
 
virtual const ParametergetParameter (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 &parameters)=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 &parameters)=0
 Update the parameters from parameters. More...
 
virtual bool matchParametersValues (const ParameterList &parameters)=0
 Update the parameters from parameters. 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 ParameterListgetParameters_ ()=0
 Get all parameters available. More...
 

Protected Attributes

double dLogLik_
 
std::string dVariable_
 
double d2LogLik_
 
std::string d2Variable_
 

Detailed Description

Definition at line 138 of file HmmLikelihood.h.

Constructor & Destructor Documentation

◆ AbstractHmmLikelihood() [1/2]

AbstractHmmLikelihood::AbstractHmmLikelihood ( )

Definition at line 47 of file HmmLikelihood.cpp.

◆ AbstractHmmLikelihood() [2/2]

AbstractHmmLikelihood::AbstractHmmLikelihood ( const AbstractHmmLikelihood adhlik)

Definition at line 53 of file HmmLikelihood.cpp.

Member Function Documentation

◆ clone()

virtual HmmLikelihood* bpp::HmmLikelihood::clone ( ) const
pure virtualinherited

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::DerivableSecondOrder.

Implemented in bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, and bpp::LogsumHmmLikelihood.

◆ computeD2Likelihood_()

virtual void bpp::HmmLikelihood::computeD2Likelihood_ ( ) const
protectedpure virtualinherited

◆ computeDLikelihood_()

virtual void bpp::HmmLikelihood::computeDLikelihood_ ( ) const
protectedpure virtualinherited

◆ d2f() [1/2]

virtual double bpp::DerivableSecondOrder::d2f ( const std::string &  variable,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the second order derivative of the function according to a given set of parameters.

Parameters
variableThe name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x^2} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 228 of file Functions.h.

References bpp::DerivableSecondOrder::getSecondOrderDerivative(), and bpp::Function::setParameters().

◆ d2f() [2/2]

virtual double bpp::DerivableSecondOrder::d2f ( const std::string &  variable1,
const std::string &  variable2,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the cross derivative of the function according to a given set of parameters.

Parameters
variable1The name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
variable2The name of the $ y $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 255 of file Functions.h.

References bpp::DerivableSecondOrder::getSecondOrderDerivative(), and bpp::Function::setParameters().

◆ df()

virtual double bpp::DerivableFirstOrder::df ( const std::string &  variable,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the first derivative of the function according to a given set of parameters.

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 173 of file Functions.h.

References bpp::DerivableFirstOrder::getFirstOrderDerivative(), and bpp::Function::setParameters().

◆ enableFirstOrderDerivatives() [1/2]

bool bpp::AbstractHmmLikelihood::enableFirstOrderDerivatives ( ) const
inlinevirtual

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableFirstOrder.

Definition at line 162 of file HmmLikelihood.h.

◆ enableFirstOrderDerivatives() [2/2]

void bpp::AbstractHmmLikelihood::enableFirstOrderDerivatives ( bool  yn)
inlinevirtual

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableFirstOrder.

Definition at line 160 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [1/2]

bool bpp::AbstractHmmLikelihood::enableSecondOrderDerivatives ( ) const
inlinevirtual

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableSecondOrder.

Definition at line 183 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [2/2]

void bpp::AbstractHmmLikelihood::enableSecondOrderDerivatives ( bool  yn)
inlinevirtual

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableSecondOrder.

Definition at line 181 of file HmmLikelihood.h.

◆ f()

◆ getBreakPoints()

virtual const std::vector<size_t>& bpp::HmmLikelihood::getBreakPoints ( ) const
pure virtualinherited

◆ getD2LogLikelihood()

double bpp::AbstractHmmLikelihood::getD2LogLikelihood ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 187 of file HmmLikelihood.h.

References d2LogLik_.

◆ getD2LogLikelihoodForASite()

virtual double bpp::HmmLikelihood::getD2LogLikelihoodForASite ( size_t  site) const
pure virtualinherited

◆ getDLogLikelihood()

double bpp::AbstractHmmLikelihood::getDLogLikelihood ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 166 of file HmmLikelihood.h.

References dLogLik_.

◆ getDLogLikelihoodForASite()

virtual double bpp::HmmLikelihood::getDLogLikelihoodForASite ( size_t  site) const
pure virtualinherited

◆ getFirstOrderDerivative()

double AbstractHmmLikelihood::getFirstOrderDerivative ( const std::string &  variable) const
virtual

Get the derivative of the function at the current point.

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::DerivableFirstOrder.

Definition at line 70 of file HmmLikelihood.cpp.

References bpp::HmmEmissionProbabilities::computeDEmissionProbabilities(), bpp::HmmLikelihood::computeDLikelihood_(), dLogLik_, dVariable_, and bpp::HmmLikelihood::getHmmEmissionProbabilities().

Referenced by bpp::LogsumHmmLikelihood::computeD2Forward_().

◆ getHiddenStatesPosteriorProbabilities()

virtual void bpp::HmmLikelihood::getHiddenStatesPosteriorProbabilities ( std::vector< std::vector< double > > &  probs,
bool  append 
) const
pure virtualinherited

◆ getHiddenStatesPosteriorProbabilitiesForASite()

virtual Vdouble bpp::HmmLikelihood::getHiddenStatesPosteriorProbabilitiesForASite ( size_t  site) const
pure virtualinherited

◆ getHmmEmissionProbabilities() [1/2]

virtual const HmmEmissionProbabilities& bpp::HmmLikelihood::getHmmEmissionProbabilities ( ) const
pure virtualinherited

◆ getHmmEmissionProbabilities() [2/2]

virtual HmmEmissionProbabilities& bpp::HmmLikelihood::getHmmEmissionProbabilities ( )
pure virtualinherited

◆ getHmmStateAlphabet() [1/2]

virtual const HmmStateAlphabet& bpp::HmmLikelihood::getHmmStateAlphabet ( ) const
pure virtualinherited

◆ getHmmStateAlphabet() [2/2]

virtual HmmStateAlphabet& bpp::HmmLikelihood::getHmmStateAlphabet ( )
pure virtualinherited

◆ getHmmTransitionMatrix() [1/2]

virtual const HmmTransitionMatrix& bpp::HmmLikelihood::getHmmTransitionMatrix ( ) const
pure virtualinherited

◆ getHmmTransitionMatrix() [2/2]

virtual HmmTransitionMatrix& bpp::HmmLikelihood::getHmmTransitionMatrix ( )
pure virtualinherited

◆ getLikelihoodForASite()

virtual double bpp::HmmLikelihood::getLikelihoodForASite ( size_t  site) const
pure virtualinherited

Get the likelihood for a site, and its derivatives.

Parameters
siteThe site index to analyse.
Returns
The likelihood for site site.

Implemented in bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, and bpp::LogsumHmmLikelihood.

◆ getLikelihoodForEachSite()

virtual Vdouble bpp::HmmLikelihood::getLikelihoodForEachSite ( ) const
pure virtualinherited

Get the likelihood for each site.

Returns
A vector with all likelihoods for each site.

Implemented in bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, and bpp::LogsumHmmLikelihood.

◆ getLogLikelihood()

virtual double bpp::HmmLikelihood::getLogLikelihood ( ) const
pure virtualinherited

◆ getNamespace()

virtual std::string bpp::Parametrizable::getNamespace ( ) const
pure virtualinherited
Returns
The current namespace used. This is an empty string if no namespace is currently defined.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getNamespace().

◆ getNumberOfParameters()

virtual size_t bpp::Parametrizable::getNumberOfParameters ( ) const
pure virtualinherited

Get the number of parameters.

See also
getNumberOfIndependentParameters If some parameters are aliased.
Returns
The number of parameters.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getNumberOfParameters(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().

◆ getParameter()

virtual const Parameter& bpp::Parametrizable::getParameter ( const std::string &  name) const
pure virtualinherited

Get the parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
The parameter with given name.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameter().

◆ getParameterNameWithoutNamespace()

virtual std::string bpp::Parametrizable::getParameterNameWithoutNamespace ( const std::string &  name) const
pure virtualinherited

Resolves a parameter name according to the current namespace.

Returns
The parameter name without the namespace prefix, if any.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameterNameWithoutNamespace(), and bpp::BppOParametrizableFormat::write().

◆ getParameters()

virtual const ParameterList& bpp::Parametrizable::getParameters ( ) const
pure virtualinherited

◆ getParameters_()

virtual ParameterList& bpp::Parametrizable::getParameters_ ( )
protectedpure virtualinherited

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

Implemented in bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameters_().

◆ getParameterValue()

virtual double bpp::Parametrizable::getParameterValue ( const std::string &  name) const
pure virtualinherited

Get the value for parameter of name 'name'.

Parameters
nameThe name of the parameter.
Returns
the value of parameter name.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameterValue().

◆ getSecondOrderDerivative() [1/2]

double AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable) const
virtual

Get the second order derivative of the function at the current point.

Parameters
variableThe name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x^2} $.
Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::DerivableSecondOrder.

Definition at line 82 of file HmmLikelihood.cpp.

References bpp::HmmEmissionProbabilities::computeD2EmissionProbabilities(), bpp::HmmLikelihood::computeD2Likelihood_(), d2LogLik_, d2Variable_, and bpp::HmmLikelihood::getHmmEmissionProbabilities().

◆ getSecondOrderDerivative() [2/2]

double bpp::AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable1,
const std::string &  variable2 
) const
inlinevirtual

Get the value of the cross derivative of the function according to a given set of parameters.

Parameters
variable1The name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
variable2The name of the $ y $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Implements bpp::DerivableSecondOrder.

Definition at line 192 of file HmmLikelihood.h.

◆ getValue()

◆ hasParameter()

virtual bool bpp::Parametrizable::hasParameter ( const std::string &  name) const
pure virtualinherited

Tell if there is a parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
y/n.

Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::hasParameter().

◆ matchParametersValues()

virtual bool bpp::Parametrizable::matchParametersValues ( const ParameterList parameters)
pure virtualinherited

Update the parameters from parameters.

Only common parameters with parameters will be updated.

Parameters
parametersA list of parameters.
Returns
True if at least one parameter value has been changed.
Exceptions
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::ParametrizableAdapter, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractParametrizable.

Referenced by bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::LogsumHmmLikelihood::fireParameterChanged(), bpp::BppODiscreteDistributionFormat::initialize_(), bpp::AbstractNumericalDerivative::matchParametersValues(), bpp::FunctionWrapper::matchParametersValues(), and bpp::InfinityFunctionWrapper::matchParametersValues().

◆ operator=()

◆ setAllParametersValues()

virtual void bpp::Parametrizable::setAllParametersValues ( const ParameterList parameters)
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
parametersA list with all parameters.
Exceptions
ParameterNotFoundExceptionIf a some parameter in the list is not in params.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::ParametrizableAdapter, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractParametrizable.

Referenced by bpp::AbstractNumericalDerivative::setAllParametersValues(), bpp::FunctionWrapper::setAllParametersValues(), and bpp::InfinityFunctionWrapper::setAllParametersValues().

◆ setBreakPoints()

virtual void bpp::HmmLikelihood::setBreakPoints ( const std::vector< size_t > &  breakPoints)
pure virtualinherited

◆ setNamespace()

virtual void bpp::Parametrizable::setNamespace ( const std::string &  prefix)
pure virtualinherited

◆ setParameters()

◆ setParametersValues()

virtual void bpp::Parametrizable::setParametersValues ( const ParameterList parameters)
pure virtualinherited

Update the parameters from parameters.

parameters must be a subset of all parameters available.

Parameters
parametersA list containing all parameters to update.
Exceptions
ParameterNotFoundExceptionIf a some parameter in params is not in the list.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::ParametrizableAdapter, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractParametrizable.

Referenced by bpp::LogsumHmmLikelihood::fireParameterChanged(), bpp::AbstractNumericalDerivative::setParametersValues(), bpp::FunctionWrapper::setParametersValues(), and bpp::InfinityFunctionWrapper::setParametersValues().

◆ setParameterValue()

virtual void bpp::Parametrizable::setParameterValue ( const std::string &  name,
double  value 
)
pure virtualinherited

Set the value of parameter with name name to be equal to value.

Parameters
namethe name of the parameter to set.
valueThe value of the parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter in the list has the name name.
ConstraintExceptionIf value does not match the constraint associated to parameter name.

Implemented in bpp::ParametrizableAdapter, bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, and bpp::AbstractParametrizable.

Referenced by bpp::AbstractNumericalDerivative::setParameterValue(), bpp::FunctionWrapper::setParameterValue(), and bpp::InfinityFunctionWrapper::setParameterValue().

Member Data Documentation

◆ d2LogLik_

double bpp::AbstractHmmLikelihood::d2LogLik_
mutableprotected

◆ d2Variable_

std::string bpp::AbstractHmmLikelihood::d2Variable_
mutableprotected

◆ dLogLik_

◆ dVariable_

std::string bpp::AbstractHmmLikelihood::dVariable_
mutableprotected

The documentation for this class was generated from the following files: