bpp-core3  3.0.0
bpp::MultipleDiscreteDistribution Class Referenceabstract

Interface for multiple discrete distribution objects. More...

#include <Bpp/Numeric/Prob/MultipleDiscreteDistribution.h>

+ Inheritance diagram for bpp::MultipleDiscreteDistribution:
+ Collaboration diagram for bpp::MultipleDiscreteDistribution:

Public Member Functions

 MultipleDiscreteDistribution ()
 
virtual ~MultipleDiscreteDistribution ()
 
MultipleDiscreteDistributionclone () const =0
 Create a copy of this object and send a pointer to it. More...
 
virtual size_t getNumberOfCategories () const =0
 
virtual Vdouble getValueCategory (Vdouble &Vvalue) const =0
 
virtual double getProbability (Vdouble &category) const =0
 
virtual Vdouble rand () const =0
 Draw a random vector from this distribution. More...
 
virtual Vdouble randC () const =0
 Draw a random vector from the continuous version of this distribution, if it exists. More...
 
virtual size_t getNumberOfIndependentParameters () const =0
 Get the number of independent parameters. More...
 
virtual void aliasParameters (const std::string &p1, const std::string &p2)=0
 Set two parameters as 'aliased'. More...
 
virtual void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)=0
 alias the parameters following the links described in a map, and update the object accordingly. Cycles in aliasing are detected and forbidden. More...
 
virtual void unaliasParameters (const std::string &p1, const std::string &p2)=0
 Detach two parameters previously set as 'aliased'. More...
 
virtual const ParameterListgetIndependentParameters () const =0
 Get the minimal list of parameters to set the model. More...
 
virtual std::vector< std::string > getAlias (const std::string &name) const =0
 
virtual std::map< std::string, std::string > getAliases () 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 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 ParameterListgetParameters_ ()=0
 Get all parameters available. More...
 

Detailed Description

Interface for multiple discrete distribution objects.

A multiple discrete distribution usually contains a vector of finite set of categories and a probability associated to each. The size of the vector is the dimension of the distribution.

Each category (or class) is defined by two bounds, and sometimes by a mean or a median value.

A multiple discrete distribution may contain one or several parameters. The probabilities associated to each class usually depends on the parameter values. In some cases, the number and/or bounds of the classes may also depend on the parameters values, depending on the kind of discretization used.

Definition at line 69 of file MultipleDiscreteDistribution.h.

Constructor & Destructor Documentation

◆ MultipleDiscreteDistribution()

bpp::MultipleDiscreteDistribution::MultipleDiscreteDistribution ( )
inline

Definition at line 73 of file MultipleDiscreteDistribution.h.

◆ ~MultipleDiscreteDistribution()

virtual bpp::MultipleDiscreteDistribution::~MultipleDiscreteDistribution ( )
inlinevirtual

Definition at line 75 of file MultipleDiscreteDistribution.h.

Member Function Documentation

◆ aliasParameters() [1/2]

virtual void bpp::ParameterAliasable::aliasParameters ( const std::string &  p1,
const std::string &  p2 
)
pure virtualinherited

Set two parameters as 'aliased'.

The values of the two parameters will be synchronized, so that setting the value of one parameter will automatically set the value of the other one accordingly.

Parameters
p1Original parameter.
p2Aliased parameter.
Exceptions
ParameterNotFoundExceptionif p1 or p2 do not correspond to existing parameters.
Exceptionwhen trying to perform non-valid association.

Implemented in bpp::AbstractParameterAliasable.

◆ aliasParameters() [2/2]

virtual void bpp::ParameterAliasable::aliasParameters ( std::map< std::string, std::string > &  unparsedParams,
bool  verbose 
)
pure virtualinherited

alias the parameters following the links described in a map, and update the object accordingly. Cycles in aliasing are detected and forbidden.

Parameters
unparsedParamsthe map of the links : <A,B> matches for A->B aliasing.
verboseverbosity

Implemented in bpp::AbstractParameterAliasable.

◆ clone()

MultipleDiscreteDistribution* bpp::MultipleDiscreteDistribution::clone ( ) const
pure virtual

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::DirichletDiscreteDistribution.

◆ getAlias()

virtual std::vector<std::string> bpp::ParameterAliasable::getAlias ( const std::string &  name) const
pure virtualinherited
Returns
The list of names of the parameters that are aliased with a given parameter. Depending on the implementation, the function may be recursive or not...
Parameters
nameThe name of the parameter to look for.

Implemented in bpp::AbstractParameterAliasable.

Referenced by bpp::BppOParametrizableFormat::write().

◆ getAliases()

virtual std::map<std::string, std::string> bpp::ParameterAliasable::getAliases ( ) const
pure virtualinherited
Returns
the map of the aliases.

Implemented in bpp::AbstractParameterAliasable.

◆ getIndependentParameters()

virtual const ParameterList& bpp::ParameterAliasable::getIndependentParameters ( ) const
pure virtualinherited

Get the minimal list of parameters to set the model.

If no parameters are aliased, this is the same a getParameters().

Returns
A minimal set of parameters.

Implemented in bpp::AbstractParameterAliasable.

Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().

◆ 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().

◆ getNumberOfCategories()

virtual size_t bpp::MultipleDiscreteDistribution::getNumberOfCategories ( ) const
pure virtual
Returns
The number of categories

Implemented in bpp::DirichletDiscreteDistribution.

◆ getNumberOfIndependentParameters()

virtual size_t bpp::ParameterAliasable::getNumberOfIndependentParameters ( ) const
pure virtualinherited

Get the number of independent parameters.

Returns
The number of independent parameters. If no parameters are aliased, this is equivalent to the getNumberOfParameters() method.

Implemented in bpp::AbstractParameterAliasable.

◆ getNumberOfParameters()

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

◆ 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()

◆ 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().

◆ getProbability()

virtual double bpp::MultipleDiscreteDistribution::getProbability ( Vdouble category) const
pure virtual
Parameters
categoryThe vector of values associated to the class.
Returns
The probability associated to a given class.

Implemented in bpp::DirichletDiscreteDistribution.

◆ getValueCategory()

virtual Vdouble bpp::MultipleDiscreteDistribution::getValueCategory ( Vdouble Vvalue) const
pure virtual
Parameters
VvalueThe vector of values to check.
Returns
The vector of categories of the classes the value is in. Throws a ConstraintException if the value is off the domain of the MultipleDiscreteDistribution.

Implemented in bpp::DirichletDiscreteDistribution.

◆ 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().

◆ rand()

virtual Vdouble bpp::MultipleDiscreteDistribution::rand ( ) const
pure virtual

Draw a random vector from this distribution.

This vector will be one of the class values, drawn according to the class probabilities.

Returns
A random number according to this distribution.

Implemented in bpp::DirichletDiscreteDistribution.

◆ randC()

virtual Vdouble bpp::MultipleDiscreteDistribution::randC ( ) const
pure virtual

Draw a random vector from the continuous version of this distribution, if it exists.

Uses the continuous version of this distribution to draw a random vector.

Returns
A random vector according to this distribution.
Exceptions
ExceptionIf there is no continuous version of this distribution.

Implemented in bpp::DirichletDiscreteDistribution.

◆ 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().

◆ setNamespace()

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

◆ 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().

◆ unaliasParameters()

virtual void bpp::ParameterAliasable::unaliasParameters ( const std::string &  p1,
const std::string &  p2 
)
pure virtualinherited

Detach two parameters previously set as 'aliased'.

The values of the two parameters will now be independent.

Parameters
p1Original parameter.
p2Aliased parameter.
Exceptions
ParameterNotFoundExceptionif p1 or p2 do not correspond to existing parameters.
Exceptionwhen trying to perform non-valid dissociation.

Implemented in bpp::AbstractParameterAliasable.


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