bpp-core3  3.0.0
bpp::AbstractHmmTransitionMatrix Class Referenceabstract

Partial implementation of HmmTransitionMatrix. More...

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

+ Inheritance diagram for bpp::AbstractHmmTransitionMatrix:
+ Collaboration diagram for bpp::AbstractHmmTransitionMatrix:

Public Member Functions

 AbstractHmmTransitionMatrix (std::shared_ptr< const HmmStateAlphabet > alph, const std::string &prefix="")
 
 AbstractHmmTransitionMatrix (const AbstractHmmTransitionMatrix &hptm)
 
AbstractHmmTransitionMatrixoperator= (const AbstractHmmTransitionMatrix &hptm)
 
std::shared_ptr< const HmmStateAlphabetgetHmmStateAlphabet () const
 
const HmmStateAlphabethmmStateAlphabet () const
 
void setHmmStateAlphabet (std::shared_ptr< const HmmStateAlphabet > stateAlphabet)
 Set the new hidden state alphabet. More...
 
size_t getNumberOfStates () const
 
std::vector< size_t > sample (size_t size) const
 sampling of a sequence of states. Starting point is sampled from the equilibrium distribution. More...
 
virtual HmmTransitionMatrixclone () const override=0
 Create a copy of this object and send a pointer to it. More...
 
virtual double Pij (size_t i, size_t j) const =0
 Get the transition probability between two states. More...
 
virtual const Matrix< double > & getPij () const =0
 Get all transition probabilities as a matrix. More...
 
virtual const std::vector< double > & getEquilibriumFrequencies () const =0
 
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 Parameterparameter (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 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 ParameterListgetParameters_ ()=0
 Get all parameters available. More...
 

Protected Attributes

RowMatrix< double > pij_
 
RowMatrix< double > tmpmat_
 
Vdouble eqFreq_
 
bool upToDate_
 

Private Attributes

std::shared_ptr< const HmmStateAlphabetalph_
 

Detailed Description

Partial implementation of HmmTransitionMatrix.

Definition at line 19 of file AbstractHmmTransitionMatrix.h.

Constructor & Destructor Documentation

◆ AbstractHmmTransitionMatrix() [1/2]

AbstractHmmTransitionMatrix::AbstractHmmTransitionMatrix ( std::shared_ptr< const HmmStateAlphabet alph,
const std::string &  prefix = "" 
)

Definition at line 13 of file AbstractHmmTransitionMatrix.cpp.

◆ AbstractHmmTransitionMatrix() [2/2]

AbstractHmmTransitionMatrix::AbstractHmmTransitionMatrix ( const AbstractHmmTransitionMatrix hptm)

Definition at line 21 of file AbstractHmmTransitionMatrix.cpp.

Member Function Documentation

◆ clone()

virtual HmmTransitionMatrix* bpp::HmmTransitionMatrix::clone ( ) const
overridepure virtualinherited

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

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Implemented in bpp::FullHmmTransitionMatrix, and bpp::AutoCorrelationTransitionMatrix.

◆ getEquilibriumFrequencies()

virtual const std::vector<double>& bpp::HmmTransitionMatrix::getEquilibriumFrequencies ( ) const
pure virtualinherited
Returns
The vector of equilibrium frequencies of the Markov chain described by the matrix.

Implemented in bpp::FullHmmTransitionMatrix, and bpp::AutoCorrelationTransitionMatrix.

◆ getHmmStateAlphabet()

std::shared_ptr<const HmmStateAlphabet> bpp::AbstractHmmTransitionMatrix::getHmmStateAlphabet ( ) const
inlinevirtual
Returns
A pointer toward the hidden alphabet associated to this model.

Implements bpp::HmmTransitionMatrix.

Definition at line 42 of file AbstractHmmTransitionMatrix.h.

References alph_.

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

Referenced by bpp::Parametrizable::~Parametrizable().

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

Referenced by bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution(), and bpp::Parametrizable::~Parametrizable().

◆ getNumberOfStates()

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

Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::Parametrizable::~Parametrizable().

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

Referenced by bpp::Parametrizable::~Parametrizable().

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

Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), and bpp::Parametrizable::~Parametrizable().

◆ getPij()

virtual const Matrix<double>& bpp::HmmTransitionMatrix::getPij ( ) const
pure virtualinherited

Get all transition probabilities as a matrix.

Returns
A n*n matrix will all transition probabilities (n being the number of hidden states).

Implemented in bpp::FullHmmTransitionMatrix, and bpp::AutoCorrelationTransitionMatrix.

Referenced by sample().

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

Referenced by bpp::Parametrizable::~Parametrizable().

◆ hmmStateAlphabet()

const HmmStateAlphabet& bpp::AbstractHmmTransitionMatrix::hmmStateAlphabet ( ) const
inlinevirtual
Returns
The hidden alphabet associated to this model.

Implements bpp::HmmTransitionMatrix.

Definition at line 50 of file AbstractHmmTransitionMatrix.h.

References alph_, and setHmmStateAlphabet().

Referenced by sample().

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

Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::TestFunction::setParameters(), and bpp::Parametrizable::~Parametrizable().

◆ operator=()

◆ parameter()

virtual const Parameter& bpp::Parametrizable::parameter ( 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::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::TestFunction::getValue(), and bpp::Parametrizable::~Parametrizable().

◆ Pij()

virtual double bpp::HmmTransitionMatrix::Pij ( size_t  i,
size_t  j 
) const
pure virtualinherited

Get the transition probability between two states.

Parameters
iinitial state.
jfinal state.
Returns
the transition probability between the two states.

Implemented in bpp::FullHmmTransitionMatrix, and bpp::AutoCorrelationTransitionMatrix.

◆ removeConstraint()

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

Remove the constraint associated with one parameter, if any.

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

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

Referenced by bpp::Parametrizable::~Parametrizable().

◆ sample()

vector< size_t > AbstractHmmTransitionMatrix::sample ( size_t  size) const

sampling of a sequence of states. Starting point is sampled from the equilibrium distribution.

Parameters
sizethe length of the sequence
Returns
a vector of states index sampled from the Transition probabilities

Definition at line 48 of file AbstractHmmTransitionMatrix.cpp.

References eqFreq_, bpp::HmmStateAlphabet::getNumberOfStates(), bpp::HmmTransitionMatrix::getPij(), bpp::RowMatrix< Scalar >::getRow(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), hmmStateAlphabet(), and pij_.

Referenced by getNumberOfStates().

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

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setConstraint()

virtual void bpp::Parametrizable::setConstraint ( const std::string &  name,
std::shared_ptr< ConstraintInterface constraint 
)
pure virtualinherited

Set/Change the constraint associated with one parameter.

Parameters
nameThe name of the parameter to look for.
constraintA pointer to the constraint (may be null)
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

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

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setHmmStateAlphabet()

void AbstractHmmTransitionMatrix::setHmmStateAlphabet ( std::shared_ptr< const HmmStateAlphabet stateAlphabet)
virtual

Set the new hidden state alphabet.

Parameters
stateAlphabetThe new state alphabet
Exceptions
UnvalidStateAlphabetExceptionif the new alphabet is uncorrect (for instance is NULL pointer).

Implements bpp::HmmTransitionMatrix.

Definition at line 40 of file AbstractHmmTransitionMatrix.cpp.

References alph_.

Referenced by hmmStateAlphabet().

◆ setNamespace()

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::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, bpp::AbstractParametrizable, and bpp::InvariantMixedDiscreteDistribution.

Referenced by bpp::Parametrizable::~Parametrizable().

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

Referenced by bpp::Parametrizable::~Parametrizable().

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

Referenced by bpp::Parametrizable::~Parametrizable().

Member Data Documentation

◆ alph_

std::shared_ptr<const HmmStateAlphabet> bpp::AbstractHmmTransitionMatrix::alph_
private

◆ eqFreq_

◆ pij_

◆ tmpmat_

RowMatrix<double> bpp::AbstractHmmTransitionMatrix::tmpmat_
mutableprotected

◆ upToDate_


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