bpp-core  2.2.0
bpp::DirichletDiscreteDistribution Class Referenceabstract

Discretized Dirichlet distribution. If the distribution is in n dimensions, the domain is the n-1 simplex. More...

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

+ Inheritance diagram for bpp::DirichletDiscreteDistribution:
+ Collaboration diagram for bpp::DirichletDiscreteDistribution:

Public Member Functions

 DirichletDiscreteDistribution (std::vector< size_t > vn, Vdouble valpha)
 Build a new discretized Dirichlet distribution. More...
 
 ~DirichletDiscreteDistribution ()
 
DirichletDiscreteDistributionclone () const
 Create a copy of this object and send a pointer to it. More...
 
std::string getName () const
 
void fireParameterChanged (const ParameterList &parameters)
 Notify the class when one or several parameters have changed. More...
 
size_t getNumberOfCategories () const
 
Vdouble getValueCategory (Vdouble &Vvalue) const
 
VVdouble getCategories () const
 
virtual double getProbability (Vdouble &category) const
 
Vdouble rand () const
 Draw a random vector from this distribution. More...
 
Vdouble randC () const
 Draw a random vector from the continuous version of this distribution. 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 throw (ParameterNotFoundException, Exception)
 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 throw (ParameterNotFoundException, Exception)
 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 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...
 
void setNamespace (const std::string &prefix)
 Set the namespace for the parameter names. More...
 
const ParameterListgetIndependentParameters () const
 Get the minimal list of parameters to set the model. More...
 
size_t getNumberOfIndependentParameters () const
 Get the number of independent parameters. More...
 
void aliasParameters (const std::string &p1, const std::string &p2) throw (ParameterNotFoundException, Exception)
 Set two parameters as 'aliased'. More...
 
void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)
 alias the parameters following the links described in a map, and update the object accordingly. Cycles in aliasing are detected and forbidden. More...
 
void unaliasParameters (const std::string &p1, const std::string &p2) throw (ParameterNotFoundException, Exception)
 Detach two parameters previously set as 'aliased'. More...
 
ParameterList getAliasedParameters (const ParameterList &pl) const
 Return the list of the names of the parameters that are aliased (directly or not) to one of the parameters of the list. More...
 
std::vector< std::string > getAlias (const std::string &name) const
 
std::string getFrom (const std::string &name) const
 
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...
 
std::string getNamespace () const
 
std::string getParameterNameWithoutNamespace (const std::string &name) const
 Resolves a parameter name according to the current namespace. More...
 

Protected Member Functions

void applyParameters ()
 
void discretize (Vdouble &valpha)
 
void addParameter_ (Parameter *parameter)
 
void addParameters_ (const ParameterList &parameters)
 
void deleteParameter_ (size_t index) throw (IndexOutOfBoundsException)
 
void deleteParameter_ (std::string &name) throw (IndexOutOfBoundsException)
 
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_ ()
 

Private Attributes

std::vector< BetaDiscreteDistribution *> vpBDD_
 

Detailed Description

Discretized Dirichlet distribution. If the distribution is in n dimensions, the domain is the n-1 simplex.

The discretization is made in the order of these dimensions. Then the order of the dimensions is not neutral on the resulting categories.

Here is an example of the discretization process: if the distribution is in 3 dimensions, and the number of categories is 4 in the first dimension, 3 in the second and 5 in the third, the first interval is split in 4 equi-probable intervals, and each interval is split on the second dimension in 3 equi-probable intervals, and each of the 12 resulting 2D intervals is split in 5 equi-probable 3D-intervals. Eventually, there are 60 equi-probable categories.

In the same example, if the distribution is followed by the random vector $ (X_1,X_2,X_3) $, the 1D distribution used for $ X_1 $ is the marginal distribution, which discretized values are say, $ v_1^1, v_1^2, v_1^3, v_1^4 $, then the four 1D distributions used for $ X_2 $ are the conditional marginal distributions $ (X_2|X_1=v_1^1), (X_2|X_1=v_1^2), (X_2|X_1=v_1^3), (X_2|X_1=v_1^4) $. And in a similar way for $ X_3 $, with the 12 resulting conditions on $ X_1 $ and $ X_2 $.

It uses the AbstractDiscreteDistribution comparator class to deal with double precision. By default, category values that differ less than 10E-9 will be considered identical.

The successive discretization process is done using the distributions, if the parameters are $ (\alpha_1, ..., \alpha_n)$:

$ X_1 $ follows Beta( $ \alpha_1, \sum_{i=2}^n \alpha_i $).

$ X_j $ follows $ (1-\sum_{i=1}^{j-1} X_i) $ * Beta( $ \alpha_j, \sum_{i=j+1}^n \alpha_i $).

$ X_n = 1 - \sum_{i=1}^{n-1} X_i $.

The parameters are: alpha_1, ... alpha_n $ \in [0.0001;\infty[ $.

Definition at line 101 of file DirichletDiscreteDistribution.h.

Constructor & Destructor Documentation

◆ DirichletDiscreteDistribution()

DirichletDiscreteDistribution::DirichletDiscreteDistribution ( std::vector< size_t >  vn,
Vdouble  valpha 
)

Build a new discretized Dirichlet distribution.

Parameters
vnthe vector of the dim-1 numbers of categories to use.
valphathe vector of the dim alpha parameters.

Constructor:

Definition at line 55 of file DirichletDiscreteDistribution.cpp.

References bpp::AbstractParameterAliasable::addParameter_(), discretize(), bpp::TextTools::toString(), and vpBDD_.

Referenced by clone().

◆ ~DirichletDiscreteDistribution()

DirichletDiscreteDistribution::~DirichletDiscreteDistribution ( )

Definition at line 81 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

Member Function Documentation

◆ addParameter_()

◆ addParameters_()

◆ aliasParameters() [1/4]

virtual void bpp::ParameterAliasable::aliasParameters ( const std::string &  p1,
const std::string &  p2 
)
throw (ParameterNotFoundException,
Exception
)
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/4]

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.

◆ aliasParameters() [3/4]

void AbstractParameterAliasable::aliasParameters ( const std::string &  p1,
const std::string &  p2 
)
throw (ParameterNotFoundException,
Exception
)
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.

Implements bpp::ParameterAliasable.

Definition at line 103 of file AbstractParameterAliasable.cpp.

References bpp::Parameter::addParameterListener(), bpp::Parameter::getConstraint(), bpp::Constraint::getDescription(), and bpp::Parameter::hasConstraint().

Referenced by bpp::ParametrizableCollection< N >::addObject().

◆ aliasParameters() [4/4]

void AbstractParameterAliasable::aliasParameters ( std::map< std::string, std::string > &  unparsedParams,
bool  verbose 
)
virtualinherited

◆ applyParameters()

void DirichletDiscreteDistribution::applyParameters ( )
protected

◆ clone()

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

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

Returns
A pointer toward the copy object.

Implements bpp::MultipleDiscreteDistribution.

Definition at line 119 of file DirichletDiscreteDistribution.h.

References DirichletDiscreteDistribution().

◆ deleteParameter_() [1/2]

◆ deleteParameter_() [2/2]

void bpp::AbstractParameterAliasable::deleteParameter_ ( std::string &  name)
throw (IndexOutOfBoundsException
)
inlineprotectedinherited

◆ deleteParameters_()

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

◆ discretize()

void DirichletDiscreteDistribution::discretize ( Vdouble valpha)
protected

◆ fireParameterChanged()

void DirichletDiscreteDistribution::fireParameterChanged ( const ParameterList parameters)
virtual

Notify the class when one or several parameters have changed.

Parameters
parametersA ParameterList object with parameters that changed.

Reimplemented from bpp::AbstractParameterAliasable.

Definition at line 91 of file DirichletDiscreteDistribution.cpp.

References applyParameters(), and bpp::AbstractParameterAliasable::fireParameterChanged().

◆ getAlias() [1/2]

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::ParametrizableCollection< N >::addObject(), and bpp::BppOParametrizableFormat::write().

◆ getAlias() [2/2]

vector< string > AbstractParameterAliasable::getAlias ( const std::string &  name) const
virtualinherited
Returns
The list of names of the parameters that are aliased with a given parameter. The implementation is recursive, which means that in the case of A->B->C, getalias(C) will return both A and B.
Parameters
nameThe name of the parameter to look for.

Implements bpp::ParameterAliasable.

Definition at line 245 of file AbstractParameterAliasable.cpp.

References bpp::AbstractParameterAliasable::aliasListenersRegister_, and bpp::VectorTools::append().

Referenced by bpp::ParametrizableCollection< N >::removeObject().

◆ getAliasedParameters()

ParameterList AbstractParameterAliasable::getAliasedParameters ( const ParameterList pl) const
inherited

Return the list of the names of the parameters that are aliased (directly or not) to one of the parameters of the list.

Definition at line 266 of file AbstractParameterAliasable.cpp.

References bpp::ParameterList::addParameter(), bpp::AbstractParameterAliasable::aliasListenersRegister_, bpp::AbstractParametrizable::getParameter(), and bpp::ParameterList::hasParameter().

◆ getCategories()

VVdouble DirichletDiscreteDistribution::getCategories ( ) const

Definition at line 195 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

◆ getFrom()

string AbstractParameterAliasable::getFrom ( const std::string &  name) const
inherited
Returns
The name of the parameter from which a given parameter is aliased.
Parameters
nameThe name of the parameter to look for.

Definition at line 306 of file AbstractParameterAliasable.cpp.

References bpp::AbstractParameterAliasable::aliasListenersRegister_.

◆ getIndependentParameters() [1/2]

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::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::BppODiscreteDistributionFormat::write(), and bpp::BppOParametrizableFormat::write().

◆ getIndependentParameters() [2/2]

const ParameterList& bpp::AbstractParameterAliasable::getIndependentParameters ( ) const
inlinevirtualinherited

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.

Implements bpp::ParameterAliasable.

Definition at line 162 of file AbstractParameterAliasable.h.

References bpp::AbstractParameterAliasable::independentParameters_.

◆ getName()

std::string bpp::DirichletDiscreteDistribution::getName ( ) const
inline

Definition at line 128 of file DirichletDiscreteDistribution.h.

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

◆ getNumberOfCategories()

size_t DirichletDiscreteDistribution::getNumberOfCategories ( ) const
virtual
Returns
The number of categories

Implements bpp::MultipleDiscreteDistribution.

Definition at line 140 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

◆ getNumberOfIndependentParameters() [1/2]

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.

◆ getNumberOfIndependentParameters() [2/2]

size_t bpp::AbstractParameterAliasable::getNumberOfIndependentParameters ( ) const
inlinevirtualinherited

Get the number of independent parameters.

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

Implements bpp::ParameterAliasable.

Definition at line 164 of file AbstractParameterAliasable.h.

References bpp::AbstractParameterAliasable::independentParameters_, and bpp::ParameterList::size().

◆ 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

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

◆ getProbability()

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

Implements bpp::MultipleDiscreteDistribution.

Definition at line 177 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

◆ getValueCategory()

Vdouble DirichletDiscreteDistribution::getValueCategory ( Vdouble Vvalue) const
virtual
Parameters
Vvalue
Returns
The vector of categoryIndex of the classes the value is in. Throws a ConstraintException if the value is off the domain of the DirichletDiscreteDistribution.

Implements bpp::MultipleDiscreteDistribution.

Definition at line 154 of file DirichletDiscreteDistribution.cpp.

References bpp::NumConstants::VERY_TINY(), and vpBDD_.

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

◆ rand()

Vdouble DirichletDiscreteDistribution::rand ( ) const
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.

Implements bpp::MultipleDiscreteDistribution.

Definition at line 249 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

◆ randC()

Vdouble DirichletDiscreteDistribution::randC ( ) const
virtual

Draw a random vector from the continuous version of this distribution.

Returns
A random vector according to this distribution.

Implements bpp::MultipleDiscreteDistribution.

Definition at line 266 of file DirichletDiscreteDistribution.cpp.

References vpBDD_.

◆ resetParameters_()

void bpp::AbstractParameterAliasable::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().

◆ setNamespace() [1/2]

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

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

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

◆ unaliasParameters() [1/2]

virtual void bpp::ParameterAliasable::unaliasParameters ( const std::string &  p1,
const std::string &  p2 
)
throw (ParameterNotFoundException,
Exception
)
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.

◆ unaliasParameters() [2/2]

void AbstractParameterAliasable::unaliasParameters ( const std::string &  p1,
const std::string &  p2 
)
throw (ParameterNotFoundException,
Exception
)
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.

Implements bpp::ParameterAliasable.

Definition at line 198 of file AbstractParameterAliasable.cpp.

Referenced by bpp::ParametrizableCollection< N >::removeObject().

Member Data Documentation

◆ vpBDD_


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