bpp-core  2.2.0
bpp::RescaledHmmLikelihood Class Referenceabstract

A simple implementation of hidden Markov models recursion. More...

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

+ Inheritance diagram for bpp::RescaledHmmLikelihood:
+ Collaboration diagram for bpp::RescaledHmmLikelihood:

Public Member Functions

 RescaledHmmLikelihood (HmmStateAlphabet *hiddenAlphabet, HmmTransitionMatrix *transitionMatrix, HmmEmissionProbabilities *emissionProbabilities, const std::string &prefix) throw (Exception)
 Build a new RescaledHmmLikelihood object. More...
 
 RescaledHmmLikelihood (const RescaledHmmLikelihood &lik)
 
RescaledHmmLikelihoodoperator= (const RescaledHmmLikelihood &lik)
 
virtual ~RescaledHmmLikelihood ()
 
RescaledHmmLikelihoodclone () const
 Create a copy of this object and send a pointer to it. More...
 
const HmmStateAlphabetgetHmmStateAlphabet () const
 
HmmStateAlphabetgetHmmStateAlphabet ()
 
const HmmTransitionMatrixgetHmmTransitionMatrix () const
 
HmmTransitionMatrixgetHmmTransitionMatrix ()
 
const HmmEmissionProbabilitiesgetHmmEmissionProbabilities () const
 
HmmEmissionProbabilitiesgetHmmEmissionProbabilities ()
 
void setBreakPoints (const std::vector< size_t > &breakPoints)
 
const std::vector< size_t > & getBreakPoints () const
 
void setParameters (const ParameterList &pl) throw (Exception)
 Set the point where the function must be computed. More...
 
double getValue () const throw (Exception)
 Get the value of the function at the current point. More...
 
double getLogLikelihood () const
 
double getLikelihoodForASite (size_t site) const
 Get the likelihood for a site. More...
 
Vdouble getLikelihoodForEachSite () const
 Get the likelihood for each site. More...
 
void fireParameterChanged (const ParameterList &pl)
 Notify the class when one or several parameters have changed. More...
 
Vdouble getHiddenStatesPosteriorProbabilitiesForASite (size_t site) const
 
void getHiddenStatesPosteriorProbabilities (std::vector< std::vector< double > > &probs, bool append=false) const throw (Exception)
 
virtual double d2f (const std::string &variable, const ParameterList &parameters) throw (Exception)
 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) throw (Exception)
 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) throw (Exception)
 Get the value of the first derivative of the function according to a given set of parameters. More...
 
virtual double f (const ParameterList &parameters) throw (Exception)
 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 throw (ParameterNotFoundException)
 Get the parameter with specified name. More...
 
virtual double getParameterValue (const std::string &name) const =0 throw (ParameterNotFoundException)
 Get the value for parameter of name 'name'. More...
 
virtual void setAllParametersValues (const ParameterList &parameters)=0 throw (ParameterNotFoundException, ConstraintException)
 Set the parameters values to be equals to those of parameters. More...
 
virtual void setParameterValue (const std::string &name, double value)=0 throw (ParameterNotFoundException, ConstraintException)
 Set the value of parameter with name name to be equal to value. More...
 
virtual void setParametersValues (const ParameterList &parameters)=0 throw (ParameterNotFoundException, ConstraintException)
 Update the parameters from parameters. More...
 
virtual bool matchParametersValues (const ParameterList &parameters)=0 throw (ConstraintException)
 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...
 
bool hasParameter (const std::string &name) const
 Tell if there is a parameter with specified name. More...
 
const ParameterListgetParameters () const
 Get all parameters available. More...
 
const ParametergetParameter (const std::string &name) const throw (ParameterNotFoundException)
 Get the parameter with specified name. More...
 
double getParameterValue (const std::string &name) const throw (ParameterNotFoundException)
 Get the value for parameter of name 'name'. More...
 
void setAllParametersValues (const ParameterList &parameters) throw (ParameterNotFoundException, ConstraintException)
 Set the parameters values to be equals to those of parameters. More...
 
void setParameterValue (const std::string &name, double value) throw (ParameterNotFoundException, ConstraintException)
 Set the value of parameter with name name to be equal to value. More...
 
void setParametersValues (const ParameterList &parameters) throw (ParameterNotFoundException, ConstraintException)
 Update the parameters from parameters. More...
 
bool matchParametersValues (const ParameterList &parameters) throw (ConstraintException)
 Update the parameters from parameters. More...
 
size_t getNumberOfParameters () const
 Get the number of parameters. More...
 
void setNamespace (const std::string &prefix)
 Set the namespace for the parameter names. More...
 
std::string getNamespace () const
 
std::string getParameterNameWithoutNamespace (const std::string &name) const
 Resolves a parameter name according to the current namespace. More...
 
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 throw (Exception)
 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 throw (Exception)
 Get the second order derivative of the function at the current point. More...
 
double getSecondOrderDerivative (const std::string &variable1, const std::string &variable2) const throw (Exception)
 Get the value of the cross derivative of the function according to a given set of parameters. More...
 
double getD2LogLikelihood () const
 

Protected Member Functions

void computeForward_ ()
 
void computeBackward_ () const
 
void computeDLikelihood_ () const
 
void computeD2Likelihood_ () const
 
void computeDForward_ () const
 
void computeD2Forward_ () const
 
void addParameter_ (Parameter *parameter)
 
void addParameters_ (const ParameterList &parameters)
 
void deleteParameter_ (size_t index) throw (IndexOutOfBoundsException)
 
void deleteParameter_ (std::string &name)
 
void deleteParameters_ (const std::vector< std::string > &names)
 
void resetParameters_ ()
 
ParametergetParameter_ (const std::string &name) throw (ParameterNotFoundException)
 
ParametergetParameter_ (size_t index) throw (IndexOutOfBoundsException)
 
const ParametergetParameter_ (size_t index) const throw (IndexOutOfBoundsException)
 
ParametergetParameterWithNamespace_ (const std::string &name) throw (ParameterNotFoundException)
 
const ParametergetParameterWithNamespace_ (const std::string &name) const throw (ParameterNotFoundException)
 
ParameterListgetParameters_ ()
 

Protected Attributes

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

Private Attributes

std::auto_ptr< HmmStateAlphabethiddenAlphabet_
 The alphabet describing the hidden states. More...
 
std::auto_ptr< HmmTransitionMatrixtransitionMatrix_
 
std::auto_ptr< HmmEmissionProbabilitiesemissionProbabilities_
 
std::vector< double > likelihood_
 The likelihood arrays. More...
 
std::vector< std::vector< double > > dLikelihood_
 derivatec of forward likelihood More...
 
std::vector< std::vector< double > > d2Likelihood_
 
std::vector< std::vector< double > > backLikelihood_
 backward likelihood More...
 
bool backLikelihoodUpToDate_
 
std::vector< double > scales_
 scales for likelihood computing More...
 
std::vector< double > dScales_
 
std::vector< double > d2Scales_
 
double logLik_
 
std::vector< size_t > breakPoints_
 
size_t nbStates_
 
size_t nbSites_
 

Detailed Description

A simple implementation of hidden Markov models recursion.

This implementation uses the rescaling method described in Durbin et al "Biological sequence analysis", Cambridge University Press. It also offer the possibility to specify "breakpoints", where the chain will be reset to the equilibrium frequencies.

Definition at line 59 of file RescaledHmmLikelihood.h.

Constructor & Destructor Documentation

◆ RescaledHmmLikelihood() [1/2]

RescaledHmmLikelihood::RescaledHmmLikelihood ( HmmStateAlphabet hiddenAlphabet,
HmmTransitionMatrix transitionMatrix,
HmmEmissionProbabilities emissionProbabilities,
const std::string &  prefix 
)
throw (Exception
)

Build a new RescaledHmmLikelihood object.

Warning
the HmmTransitionMatrix and HmmEmissionProbabilities object passed as argument must be non-null and point toward the same HmmStateAlphabet instance. The three object will be copied if needed, and deleted when the hmm likelihood objet is deleted. You should secure a copy before if you don't want them to be destroyed with this object.

Definition at line 50 of file RescaledHmmLikelihood.cpp.

Referenced by clone().

◆ RescaledHmmLikelihood() [2/2]

bpp::RescaledHmmLikelihood::RescaledHmmLikelihood ( const RescaledHmmLikelihood lik)
inline

◆ ~RescaledHmmLikelihood()

virtual bpp::RescaledHmmLikelihood::~RescaledHmmLikelihood ( )
inlinevirtual

Definition at line 187 of file RescaledHmmLikelihood.h.

Member Function Documentation

◆ addParameter_()

◆ addParameters_()

void bpp::AbstractParametrizable::addParameters_ ( const ParameterList parameters)
inlineprotectedinherited

◆ clone()

RescaledHmmLikelihood* bpp::RescaledHmmLikelihood::clone ( ) const
inlinevirtual

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

Returns
A pointer toward the copy object.

Implements bpp::HmmLikelihood.

Definition at line 194 of file RescaledHmmLikelihood.h.

References RescaledHmmLikelihood().

◆ computeBackward_()

void RescaledHmmLikelihood::computeBackward_ ( ) const
protected

Definition at line 240 of file RescaledHmmLikelihood.cpp.

◆ computeD2Forward_()

void RescaledHmmLikelihood::computeD2Forward_ ( ) const
protected

Definition at line 474 of file RescaledHmmLikelihood.cpp.

References bpp::VectorTools::sum().

Referenced by computeD2Likelihood_().

◆ computeD2Likelihood_()

void bpp::RescaledHmmLikelihood::computeD2Likelihood_ ( ) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 244 of file RescaledHmmLikelihood.h.

References computeD2Forward_().

◆ computeDForward_()

void RescaledHmmLikelihood::computeDForward_ ( ) const
protected

Definition at line 375 of file RescaledHmmLikelihood.cpp.

References bpp::VectorTools::sum().

Referenced by computeDLikelihood_().

◆ computeDLikelihood_()

void bpp::RescaledHmmLikelihood::computeDLikelihood_ ( ) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 239 of file RescaledHmmLikelihood.h.

References computeDForward_().

◆ computeForward_()

void RescaledHmmLikelihood::computeForward_ ( )
protected

◆ d2f() [1/2]

virtual double bpp::DerivableSecondOrder::d2f ( const std::string &  variable,
const ParameterList parameters 
)
throw (Exception
)
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 236 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 
)
throw (Exception
)
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 263 of file Functions.h.

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

◆ deleteParameter_() [1/2]

void bpp::AbstractParametrizable::deleteParameter_ ( size_t  index)
throw (IndexOutOfBoundsException
)
inlineprotectedinherited

◆ deleteParameter_() [2/2]

void bpp::AbstractParametrizable::deleteParameter_ ( std::string &  name)
inlineprotectedinherited

◆ deleteParameters_()

void bpp::AbstractParametrizable::deleteParameters_ ( const std::vector< std::string > &  names)
inlineprotectedinherited

◆ df()

virtual double bpp::DerivableFirstOrder::df ( const std::string &  variable,
const ParameterList parameters 
)
throw (Exception
)
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 176 of file Functions.h.

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

◆ enableFirstOrderDerivatives() [1/2]

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

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableFirstOrder.

Definition at line 163 of file HmmLikelihood.h.

◆ enableFirstOrderDerivatives() [2/2]

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

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableFirstOrder.

Definition at line 165 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [1/2]

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

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableSecondOrder.

Definition at line 185 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [2/2]

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

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableSecondOrder.

Definition at line 187 of file HmmLikelihood.h.

◆ f()

◆ fireParameterChanged()

void RescaledHmmLikelihood::fireParameterChanged ( const ParameterList parameters)
virtual

Notify the class when one or several parameters have changed.

Parameters
parametersA ParameterList object with parameters that changed.

Implements bpp::AbstractParametrizable.

Definition at line 97 of file RescaledHmmLikelihood.cpp.

◆ getBreakPoints()

const std::vector<size_t>& bpp::RescaledHmmLikelihood::getBreakPoints ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 212 of file RescaledHmmLikelihood.h.

References breakPoints_.

◆ getD2LogLikelihood()

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

Implements bpp::HmmLikelihood.

Definition at line 191 of file HmmLikelihood.h.

References bpp::AbstractHmmLikelihood::d2LogLik_.

◆ getDLogLikelihood()

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

Implements bpp::HmmLikelihood.

Definition at line 169 of file HmmLikelihood.h.

References bpp::AbstractHmmLikelihood::dLogLik_.

◆ getFirstOrderDerivative()

double AbstractHmmLikelihood::getFirstOrderDerivative ( const std::string &  variable) const
throw (Exception
)
virtualinherited

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 68 of file HmmLikelihood.cpp.

◆ getHiddenStatesPosteriorProbabilities()

void RescaledHmmLikelihood::getHiddenStatesPosteriorProbabilities ( std::vector< std::vector< double > > &  probs,
bool  append = false 
) const
throw (Exception
)
virtual

Implements bpp::HmmLikelihood.

Definition at line 351 of file RescaledHmmLikelihood.cpp.

◆ getHiddenStatesPosteriorProbabilitiesForASite()

Vdouble RescaledHmmLikelihood::getHiddenStatesPosteriorProbabilitiesForASite ( size_t  site) const
virtual

Implements bpp::HmmLikelihood.

Definition at line 335 of file RescaledHmmLikelihood.cpp.

◆ getHmmEmissionProbabilities() [1/2]

const HmmEmissionProbabilities& bpp::RescaledHmmLikelihood::getHmmEmissionProbabilities ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 203 of file RescaledHmmLikelihood.h.

References emissionProbabilities_.

◆ getHmmEmissionProbabilities() [2/2]

HmmEmissionProbabilities& bpp::RescaledHmmLikelihood::getHmmEmissionProbabilities ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 204 of file RescaledHmmLikelihood.h.

References emissionProbabilities_.

◆ getHmmStateAlphabet() [1/2]

const HmmStateAlphabet& bpp::RescaledHmmLikelihood::getHmmStateAlphabet ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 197 of file RescaledHmmLikelihood.h.

References hiddenAlphabet_.

◆ getHmmStateAlphabet() [2/2]

HmmStateAlphabet& bpp::RescaledHmmLikelihood::getHmmStateAlphabet ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 198 of file RescaledHmmLikelihood.h.

References hiddenAlphabet_.

◆ getHmmTransitionMatrix() [1/2]

const HmmTransitionMatrix& bpp::RescaledHmmLikelihood::getHmmTransitionMatrix ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 200 of file RescaledHmmLikelihood.h.

References transitionMatrix_.

◆ getHmmTransitionMatrix() [2/2]

HmmTransitionMatrix& bpp::RescaledHmmLikelihood::getHmmTransitionMatrix ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 201 of file RescaledHmmLikelihood.h.

References transitionMatrix_.

◆ getLikelihoodForASite()

double RescaledHmmLikelihood::getLikelihoodForASite ( size_t  site) const
virtual

Get the likelihood for a site.

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

Implements bpp::HmmLikelihood.

Definition at line 307 of file RescaledHmmLikelihood.cpp.

◆ getLikelihoodForEachSite()

Vdouble RescaledHmmLikelihood::getLikelihoodForEachSite ( ) const
virtual

Get the likelihood for each site.

Returns
A vector with all likelihoods for each site.

Implements bpp::HmmLikelihood.

Definition at line 317 of file RescaledHmmLikelihood.cpp.

◆ getLogLikelihood()

double bpp::RescaledHmmLikelihood::getLogLikelihood ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 221 of file RescaledHmmLikelihood.h.

References logLik_.

◆ getNamespace() [1/2]

std::string bpp::AbstractParametrizable::getNamespace ( ) const
inlinevirtualinherited

◆ getNamespace() [2/2]

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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ getNumberOfParameters() [1/2]

size_t bpp::AbstractParametrizable::getNumberOfParameters ( ) const
inlinevirtualinherited

◆ getNumberOfParameters() [2/2]

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::FunctionWrapper, bpp::ParametrizableAdapter, bpp::AbstractParametrizable, and bpp::DirectionFunction.

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

◆ getParameter() [1/2]

const Parameter& bpp::AbstractParametrizable::getParameter ( const std::string &  name) const
throw (ParameterNotFoundException
)
inlinevirtualinherited

◆ getParameter() [2/2]

virtual const Parameter& bpp::Parametrizable::getParameter ( const std::string &  name) const
throw (ParameterNotFoundException
)
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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ getParameter_() [1/3]

◆ getParameter_() [2/3]

Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index)
throw (IndexOutOfBoundsException
)
inlineprotectedinherited

◆ getParameter_() [3/3]

const Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index) const
throw (IndexOutOfBoundsException
)
inlineprotectedinherited

◆ getParameterNameWithoutNamespace() [1/2]

std::string AbstractParametrizable::getParameterNameWithoutNamespace ( const std::string &  name) const
virtualinherited

Resolves a parameter name according to the current namespace.

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

Implements bpp::Parametrizable.

Definition at line 63 of file AbstractParametrizable.cpp.

References bpp::TextTools::startsWith().

◆ getParameterNameWithoutNamespace() [2/2]

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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ getParameters() [1/2]

const ParameterList& bpp::AbstractParametrizable::getParameters ( ) const
inlinevirtualinherited

Get all parameters available.

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

Implements bpp::Parametrizable.

Definition at line 77 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::parameters_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), and bpp::ParametrizableCollection< N >::removeObject().

◆ getParameters() [2/2]

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

◆ getParameters_()

ParameterList& bpp::AbstractParametrizable::getParameters_ ( )
inlineprotectedinherited

◆ getParameterValue() [1/2]

◆ getParameterValue() [2/2]

virtual double bpp::Parametrizable::getParameterValue ( const std::string &  name) const
throw (ParameterNotFoundException
)
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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameterValue(), and bpp::BppODiscreteDistributionFormat::read().

◆ getParameterWithNamespace_() [1/2]

Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name)
throw (ParameterNotFoundException
)
inlineprotectedinherited
Parameters
nameThe name of the parameter, including its namespace.
Returns
A reference toward the corresponding parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter with that name is found in the list.

Definition at line 185 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::getParameter_().

◆ getParameterWithNamespace_() [2/2]

const Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name) const
throw (ParameterNotFoundException
)
inlineprotectedinherited
Parameters
nameThe name of the parameter, including its namespace.
Returns
A reference toward the corresponding parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter with that name is found in the list.

Definition at line 194 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::getParameter().

◆ getSecondOrderDerivative() [1/2]

double AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable) const
throw (Exception
)
virtualinherited

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 80 of file HmmLikelihood.cpp.

◆ getSecondOrderDerivative() [2/2]

double bpp::AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable1,
const std::string &  variable2 
) const
throw (Exception
)
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} $.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Implements bpp::DerivableSecondOrder.

Definition at line 196 of file HmmLikelihood.h.

◆ getValue()

double bpp::RescaledHmmLikelihood::getValue ( ) const
throw (Exception
)
inlinevirtual

Get the value of the function at the current point.

Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::Function.

Definition at line 219 of file RescaledHmmLikelihood.h.

References logLik_.

◆ hasParameter() [1/2]

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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ hasParameter() [2/2]

bool bpp::AbstractParametrizable::hasParameter ( const std::string &  name) const
inlinevirtualinherited

Tell if there is a parameter with specified name.

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

Implements bpp::Parametrizable.

Definition at line 75 of file AbstractParametrizable.h.

References bpp::ParameterList::hasParameter(), bpp::AbstractParametrizable::parameters_, and bpp::AbstractParametrizable::prefix_.

◆ matchParametersValues() [1/2]

bool bpp::AbstractParametrizable::matchParametersValues ( const ParameterList parameters)
throw (ConstraintException
)
inlinevirtualinherited

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.

Implements bpp::Parametrizable.

Definition at line 111 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::fireParameterChanged(), bpp::ParameterList::matchParametersValues(), and bpp::AbstractParametrizable::parameters_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::Simplex::setFrequencies(), bpp::ReparametrizationFunctionWrapper::setParameters(), bpp::TestFunction::setParameters(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().

◆ matchParametersValues() [2/2]

virtual bool bpp::Parametrizable::matchParametersValues ( const ParameterList parameters)
throw (ConstraintException
)
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::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ operator=()

◆ resetParameters_()

void bpp::AbstractParametrizable::resetParameters_ ( )
inlineprotectedinherited

◆ setAllParametersValues() [1/2]

void bpp::AbstractParametrizable::setAllParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
inlinevirtualinherited

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.

Implements bpp::Parametrizable.

Definition at line 90 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::fireParameterChanged(), bpp::AbstractParametrizable::parameters_, and bpp::ParameterList::setAllParametersValues().

◆ setAllParametersValues() [2/2]

virtual void bpp::Parametrizable::setAllParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
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::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ setBreakPoints()

void bpp::RescaledHmmLikelihood::setBreakPoints ( const std::vector< size_t > &  breakPoints)
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 206 of file RescaledHmmLikelihood.h.

References backLikelihoodUpToDate_, breakPoints_, and computeForward_().

◆ setNamespace() [1/2]

void AbstractParametrizable::setNamespace ( const std::string &  prefix)
virtualinherited

Set the namespace for the parameter names.

Parameters
prefixThe 'namespace', that is a prefix to add to all parameter names. If parameter names are already prefixed, the new prefix will be used instead.

Implements bpp::Parametrizable.

Reimplemented in bpp::MixtureOfDiscreteDistributions, and bpp::InvariantMixedDiscreteDistribution.

Definition at line 45 of file AbstractParametrizable.cpp.

References bpp::TextTools::startsWith().

Referenced by bpp::AbstractParameterAliasable::setNamespace().

◆ setNamespace() [2/2]

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

Set the namespace for the parameter names.

Parameters
prefixThe '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::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, bpp::AbstractParametrizable, and bpp::InvariantMixedDiscreteDistribution.

Referenced by bpp::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::InvariantMixedDiscreteDistribution::setNamespace(), and bpp::FunctionWrapper::setNamespace().

◆ setParameters()

void bpp::RescaledHmmLikelihood::setParameters ( const ParameterList parameters)
throw (Exception
)
inlinevirtual

Set the point where the function must be computed.

Parameters
parametersThe parameter set to pass to the function.

Implements bpp::Function.

Definition at line 214 of file RescaledHmmLikelihood.h.

References bpp::AbstractParametrizable::setParametersValues().

◆ setParametersValues() [1/2]

void bpp::AbstractParametrizable::setParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
inlinevirtualinherited

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.

Implements bpp::Parametrizable.

Definition at line 104 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::fireParameterChanged(), bpp::AbstractParametrizable::parameters_, and bpp::ParameterList::setParametersValues().

Referenced by bpp::LowMemoryRescaledHmmLikelihood::setParameters(), bpp::LogsumHmmLikelihood::setParameters(), and setParameters().

◆ setParametersValues() [2/2]

virtual void bpp::Parametrizable::setParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
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::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

◆ setParameterValue() [1/2]

void bpp::AbstractParametrizable::setParameterValue ( const std::string &  name,
double  value 
)
throw (ParameterNotFoundException,
ConstraintException
)
inlinevirtualinherited

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.

Implements bpp::Parametrizable.

Definition at line 97 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::fireParameterChanged(), bpp::AbstractParametrizable::parameters_, bpp::AbstractParametrizable::prefix_, bpp::ParameterList::setParameterValue(), and bpp::ParameterList::subList().

◆ setParameterValue() [2/2]

virtual void bpp::Parametrizable::setParameterValue ( const std::string &  name,
double  value 
)
throw (ParameterNotFoundException,
ConstraintException
)
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::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

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

Member Data Documentation

◆ backLikelihood_

std::vector<std::vector<double> > bpp::RescaledHmmLikelihood::backLikelihood_
mutableprivate

backward likelihood

backLikelihood_[i][j] corresponds to Pr(x_i+1...x_n | yi=j), where the x are the observed states, and y the hidden states.

Definition at line 102 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ backLikelihoodUpToDate_

bool bpp::RescaledHmmLikelihood::backLikelihoodUpToDate_
mutableprivate

Definition at line 103 of file RescaledHmmLikelihood.h.

Referenced by operator=(), and setBreakPoints().

◆ breakPoints_

std::vector<size_t> bpp::RescaledHmmLikelihood::breakPoints_
private

Definition at line 118 of file RescaledHmmLikelihood.h.

Referenced by getBreakPoints(), operator=(), and setBreakPoints().

◆ d2Likelihood_

std::vector<std::vector<double> > bpp::RescaledHmmLikelihood::d2Likelihood_
mutableprivate

Definition at line 93 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ d2LogLik_

double bpp::AbstractHmmLikelihood::d2LogLik_
mutableprotectedinherited

◆ d2Scales_

std::vector<double> bpp::RescaledHmmLikelihood::d2Scales_
mutableprivate

Definition at line 115 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ d2Variable_

std::string bpp::AbstractHmmLikelihood::d2Variable_
mutableprotectedinherited

Definition at line 148 of file HmmLikelihood.h.

Referenced by bpp::AbstractHmmLikelihood::operator=().

◆ dLikelihood_

std::vector<std::vector<double> > bpp::RescaledHmmLikelihood::dLikelihood_
mutableprivate

derivatec of forward likelihood

dlikelihood_[i][j] corresponds to d(Pr(x_1...x_i, y_i=j))/Pr(x_1...x_i)), where the x are the observed states, and y the hidden states.

Definition at line 92 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ dLogLik_

double bpp::AbstractHmmLikelihood::dLogLik_
mutableprotectedinherited

◆ dScales_

std::vector<double> bpp::RescaledHmmLikelihood::dScales_
mutableprivate

Definition at line 114 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ dVariable_

std::string bpp::AbstractHmmLikelihood::dVariable_
mutableprotectedinherited

Definition at line 145 of file HmmLikelihood.h.

Referenced by bpp::AbstractHmmLikelihood::operator=().

◆ emissionProbabilities_

std::auto_ptr<HmmEmissionProbabilities> bpp::RescaledHmmLikelihood::emissionProbabilities_
private

◆ hiddenAlphabet_

std::auto_ptr<HmmStateAlphabet> bpp::RescaledHmmLikelihood::hiddenAlphabet_
private

The alphabet describing the hidden states.

Definition at line 67 of file RescaledHmmLikelihood.h.

Referenced by getHmmStateAlphabet(), operator=(), and RescaledHmmLikelihood().

◆ likelihood_

std::vector<double> bpp::RescaledHmmLikelihood::likelihood_
private

The likelihood arrays.

forward likelihood

likelihood_[i * nbStates_ + j] corresponds to Pr(x_1...x_i, y_i=j)/Pr(x_1...x_i), where the x are the observed states, and y the hidden states.

Definition at line 83 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ logLik_

double bpp::RescaledHmmLikelihood::logLik_
private

Definition at line 116 of file RescaledHmmLikelihood.h.

Referenced by getLogLikelihood(), getValue(), and operator=().

◆ nbSites_

size_t bpp::RescaledHmmLikelihood::nbSites_
private

Definition at line 120 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ nbStates_

size_t bpp::RescaledHmmLikelihood::nbStates_
private

Definition at line 120 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ scales_

std::vector<double> bpp::RescaledHmmLikelihood::scales_
private

scales for likelihood computing

scales_[i * nbStates_ + j] corresponds to Pr(x_1...x_i)/Pr(x_1...x_{i-1}) where the x are the observed states.

Definition at line 112 of file RescaledHmmLikelihood.h.

Referenced by operator=().

◆ transitionMatrix_

std::auto_ptr<HmmTransitionMatrix> bpp::RescaledHmmLikelihood::transitionMatrix_
private

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