bpp-core3
3.0.0
|
Interface for discrete distribution objects. More...
#include <Bpp/Numeric/Prob/DiscreteDistribution.h>
Public Member Functions | |
DiscreteDistribution () | |
virtual | ~DiscreteDistribution () |
DiscreteDistribution * | clone () const =0 |
Create a copy of this object and send a pointer to it. More... | |
virtual std::string | getName () const =0 |
Get the name of the distribution. More... | |
virtual size_t | getNumberOfCategories () const =0 |
virtual void | setNumberOfCategories (size_t nbClasses)=0 |
sets the number of categories and discretizes if there is a change in this number. More... | |
virtual double | getValueCategory (double value) const =0 |
virtual size_t | getCategoryIndex (double value) const =0 |
virtual double | getCategory (size_t categoryIndex) const =0 |
virtual double | getProbability (size_t categoryIndex) const =0 |
virtual double | getProbability (double category) const =0 |
virtual Vdouble | getCategories () const =0 |
virtual Vdouble | getProbabilities () const =0 |
virtual void | set (double category, double probability)=0 |
Set the probability associated to a class. More... | |
virtual void | add (double category, double probability)=0 |
Modify the probability associated to a class. More... | |
virtual double | getInfCumulativeProbability (double category) const =0 |
virtual double | getIInfCumulativeProbability (double category) const =0 |
virtual double | getSupCumulativeProbability (double category) const =0 |
virtual double | getSSupCumulativeProbability (double category) const =0 |
virtual double | rand () const =0 |
Draw a random number from this distribution. More... | |
virtual double | randC () const =0 |
Draw a random number from the continuous version of this distribution, if it exists. More... | |
virtual double | qProb (double x) const =0 |
Return the quantile of the continuous version of the distribution, ie y such that . More... | |
virtual double | pProb (double x) const =0 |
Return the cumulative quantile of the continuous version of the distribution, ie . More... | |
virtual double | Expectation (double a) const =0 |
Return a primitive function used for the expectation of the continuous version of the distribution, ie . More... | |
virtual void | setMedian (bool median)=0 |
Sets the median value to true to say that the value in a class is proportional to the median value of the class, the proportionality factor being such that the sum of the values equals the expectation of the distribution. If it is set to false, the value is the mean value in the class. More... | |
virtual void | discretize ()=0 |
Discretizes the distribution in equiprobable classes. More... | |
virtual Vdouble | getBounds () const =0 |
virtual double | getBound (size_t) const =0 |
virtual double | getLowerBound () const |
methods about the range of the definition More... | |
virtual double | getUpperBound () const |
virtual bool | strictLowerBound () const |
virtual bool | strictUpperBound () const |
virtual void | restrictToConstraint (const Constraint &c)=0 |
Restricts the distribution to the domain where the constraint is respected, in addition of other predefined constraints. More... | |
virtual void | print (OutputStream &out) const =0 |
Print the distribution (categories and corresponding probabilities) to a stream. 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 ParameterList & | getIndependentParameters () 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 ParameterList & | getParameters () const =0 |
Get all parameters available. More... | |
virtual const Parameter & | getParameter (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 ¶meters)=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 ¶meters)=0 |
Update the parameters from parameters. More... | |
virtual bool | matchParametersValues (const ParameterList ¶meters)=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 ParameterList & | getParameters_ ()=0 |
Get all parameters available. More... | |
Interface for discrete distribution objects.
A discrete distribution usually contains a finite set of categories and a probability associated to each.
Each category (or class) is defined by two bounds, and sometimes by a mean or a median value.
A 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 DiscreteDistribution.h.
|
inline |
Definition at line 73 of file DiscreteDistribution.h.
|
inlinevirtual |
Definition at line 74 of file DiscreteDistribution.h.
|
pure virtual |
Modify the probability associated to a class.
If the category does not exist, a new category is created with the corresponding probability. if the category exists, add 'probability' to the existing probability. The sum of all probabilities is not checked.
category | The class value. |
probability | The class probability. |
Implemented in bpp::AbstractDiscreteDistribution.
|
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.
p1 | Original parameter. |
p2 | Aliased parameter. |
ParameterNotFoundException | if p1 or p2 do not correspond to existing parameters. |
Exception | when trying to perform non-valid association. |
Implemented in bpp::AbstractParameterAliasable.
|
pure virtualinherited |
alias the parameters following the links described in a map, and update the object accordingly. Cycles in aliasing are detected and forbidden.
unparsedParams | the map of the links : <A,B> matches for A->B aliasing. |
verbose | verbosity |
Implemented in bpp::AbstractParameterAliasable.
|
pure virtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, and bpp::BetaDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::operator=().
|
pure virtual |
Discretizes the distribution in equiprobable classes.
Implemented in bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::ConstantDistribution, and bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::discretize().
|
pure virtual |
Return a primitive function used for the expectation of the continuous version of the distribution, ie .
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, and bpp::BetaDiscreteDistribution.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), and bpp::InvariantMixedDiscreteDistribution::Expectation().
|
pure virtualinherited |
name | The name of the parameter to look for. |
Implemented in bpp::AbstractParameterAliasable.
Referenced by bpp::BppOParametrizableFormat::write().
|
pure virtualinherited |
Implemented in bpp::AbstractParameterAliasable.
|
pure virtual |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtual |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
categoryIndex | Class index. |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), and bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
value |
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtual |
|
pure virtualinherited |
Get the minimal list of parameters to set the model.
If no parameters are aliased, this is the same a getParameters().
Implemented in bpp::AbstractParameterAliasable.
Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
pure virtual |
|
inlinevirtual |
methods about the range of the definition
Reimplemented in bpp::SimpleDiscreteDistribution, bpp::ConstantDistribution, and bpp::AbstractDiscreteDistribution.
Definition at line 278 of file DiscreteDistribution.h.
References bpp::NumConstants::VERY_BIG().
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
Get the name of the distribution.
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, and bpp::BetaDiscreteDistribution.
Referenced by bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
pure virtualinherited |
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getNamespace().
|
pure virtual |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::InvariantMixedDiscreteDistribution::updateDistribution(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
pure virtualinherited |
Get the number of independent parameters.
Implemented in bpp::AbstractParameterAliasable.
|
pure virtualinherited |
Get the number of parameters.
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getNumberOfParameters(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
pure virtualinherited |
Get the parameter with specified name.
name | The name of the parameter to look for. |
ParameterNotFoundException | if no parameter with this name is found. |
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getParameter().
|
pure virtualinherited |
Resolves a parameter name according to the current namespace.
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getParameterNameWithoutNamespace(), and bpp::BppOParametrizableFormat::write().
|
pure virtualinherited |
Get all parameters available.
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.
Referenced by bpp::NewtonOneDimension::doStep(), bpp::LogsumHmmLikelihood::fireParameterChanged(), bpp::FunctionWrapper::getParameters(), bpp::LogsumHmmLikelihood::LogsumHmmLikelihood(), bpp::AbstractNumericalDerivative::setParameterValue(), bpp::AbstractOptimizer::step(), and bpp::BppOParametrizableFormat::write().
|
protectedpure virtualinherited |
Get all parameters available.
Implemented in bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getParameters_().
|
pure virtualinherited |
Get the value for parameter of name 'name'.
name | The name of the parameter. |
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::getParameterValue().
|
pure virtual |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
category | The value associated to the class. |
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtual |
categoryIndex | Class index. |
Implemented in bpp::AbstractDiscreteDistribution.
Referenced by bpp::BppODiscreteDistributionFormat::initialize_().
|
pure virtual |
|
pure virtual |
|
inlinevirtual |
Reimplemented in bpp::SimpleDiscreteDistribution, bpp::ConstantDistribution, and bpp::AbstractDiscreteDistribution.
Definition at line 286 of file DiscreteDistribution.h.
References bpp::NumConstants::VERY_BIG().
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtual |
value |
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtualinherited |
Tell if there is a parameter with specified name.
name | The name of the parameter to look for. |
Implemented in bpp::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.
Referenced by bpp::FunctionWrapper::hasParameter().
|
pure virtualinherited |
Update the parameters from parameters.
Only common parameters with parameters will be updated.
parameters | A list of parameters. |
ConstraintException | If 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().
|
pure virtual |
Return the cumulative quantile of the continuous version of the distribution, ie .
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, and bpp::BetaDiscreteDistribution.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), bpp::InvariantMixedDiscreteDistribution::pProb(), and bpp::InvariantMixedDiscreteDistribution::qProb().
|
pure virtual |
Print the distribution (categories and corresponding probabilities) to a stream.
out | The outstream where to print the distribution. |
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtual |
Return the quantile of the continuous version of the distribution, ie y such that .
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, and bpp::BetaDiscreteDistribution.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), and bpp::InvariantMixedDiscreteDistribution::qProb().
|
pure virtual |
Draw a random number from this distribution.
This number will be one of the class values, drawn according to the class probabilities.
Implemented in bpp::AbstractDiscreteDistribution.
|
pure virtual |
Draw a random number from the continuous version of this distribution, if it exists.
Uses the continuous version of this distribution to draw a random number.
Exception | If there is no continuous version of this distribution. |
Implemented in bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ConstantDistribution, bpp::BetaDiscreteDistribution, and bpp::AbstractDiscreteDistribution.
|
pure virtual |
Restricts the distribution to the domain where the constraint is respected, in addition of other predefined constraints.
If the domain interval is modified, the discretization process is launched.
c | The Constraint to respect. |
Implemented in bpp::TruncatedExponentialDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::ConstantDistribution, and bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::restrictToConstraint().
|
pure virtual |
Set the probability associated to a class.
If the category does not exist, a new category is created with the corresponding probability. If the category already exist, its probability is set to 'probability'. The sum of all probabilities is not checked.
category | The class value. |
probability | The class probability. |
Implemented in bpp::AbstractDiscreteDistribution.
|
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 | A list with all parameters. |
ParameterNotFoundException | If a some parameter in the list is not in params. |
ConstraintException | If 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().
|
pure virtual |
Sets the median value to true to say that the value in a class is proportional to the median value of the class, the proportionality factor being such that the sum of the values equals the expectation of the distribution. If it is set to false, the value is the mean value in the class.
If the median value is modified, the discretization process is launched.
median | tells how the value associated to each class is computed. |
Implemented in bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, and bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::setMedian().
|
pure virtualinherited |
Set the namespace for the parameter names.
prefix | The '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::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::ParametrizableAdapter, bpp::FunctionWrapper, bpp::AbstractParametrizable, bpp::AbstractParameterAliasable, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, and bpp::LogsumHmmLikelihood.
Referenced by bpp::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::LogsumHmmLikelihood::setNamespace(), bpp::FunctionWrapper::setNamespace(), and bpp::InvariantMixedDiscreteDistribution::setNamespace().
|
pure virtual |
sets the number of categories and discretizes if there is a change in this number.
Implemented in bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, and bpp::AbstractDiscreteDistribution.
Referenced by bpp::InvariantMixedDiscreteDistribution::setNumberOfCategories().
|
pure virtualinherited |
Update the parameters from parameters.
parameters must be a subset of all parameters available.
parameters | A list containing all parameters to update. |
ParameterNotFoundException | If a some parameter in params is not in the list. |
ConstraintException | If 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().
|
pure virtualinherited |
Set the value of parameter with name name to be equal to value.
name | the name of the parameter to set. |
value | The value of the parameter. |
ParameterNotFoundException | If no parameter in the list has the name name. |
ConstraintException | If 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().
|
inlinevirtual |
Reimplemented in bpp::AbstractDiscreteDistribution.
Definition at line 294 of file DiscreteDistribution.h.
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
inlinevirtual |
Reimplemented in bpp::AbstractDiscreteDistribution.
Definition at line 302 of file DiscreteDistribution.h.
Referenced by bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
pure virtualinherited |
Detach two parameters previously set as 'aliased'.
The values of the two parameters will now be independent.
p1 | Original parameter. |
p2 | Aliased parameter. |
ParameterNotFoundException | if p1 or p2 do not correspond to existing parameters. |
Exception | when trying to perform non-valid dissociation. |
Implemented in bpp::AbstractParameterAliasable.