![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
class NumericalDiscreteVariable More...
#include <numericalDiscreteVariable.h>
Public Member Functions | |
| Idx | operator[] (const std::string &label) const |
| from the label to its index in var. | |
| std::string | toString () const |
| string version of *this | |
| std::string | toStringWithDescription () const |
| string version of *this using description attribute instead of name. | |
Constructors / Destructors | |
| NumericalDiscreteVariable (const std::string &aName, const std::string &aDesc="") | |
| constructor | |
| NumericalDiscreteVariable (const std::string &aName, const std::string &aDesc, const std::vector< double > &domain) | |
| constructor assigning a domain to the variable | |
| NumericalDiscreteVariable (const std::string &aName, const std::string &aDesc, double first, double last, Size nb) | |
| constructor assigning a domain to the variable | |
| NumericalDiscreteVariable (const NumericalDiscreteVariable &from) | |
| Copy constructor. | |
| NumericalDiscreteVariable (NumericalDiscreteVariable &&from) | |
| move constructor | |
| NumericalDiscreteVariable * | clone () const final |
| virtual copy constructor | |
| virtual | ~NumericalDiscreteVariable () |
| destructor | |
Operators | |
| NumericalDiscreteVariable & | operator= (const NumericalDiscreteVariable &from) |
| copy operator | |
| NumericalDiscreteVariable & | operator= (NumericalDiscreteVariable &&from) |
| move operator | |
Accessors / Modifiers | |
| Size | domainSize () const final |
| returns the domain size of the discrete random variable | |
| VarType | varType () const final |
| returns the type of variable | |
| std::string | toFast () const final |
| returns the domain size of the discrete random variable | |
| Idx | index (const std::string &label) const final |
| returns the index of a given label | |
| Idx | closestIndex (double val) const final |
| gives the index of the value closest to val | |
| std::string | label (Idx index) const final |
| returns a string corresponding to the ith value of the domain | |
| double | numerical (Idx index) const final |
| get a numerical representation of the value at a given index | |
| std::string | domain () const final |
| Returns the domain as a string. | |
| std::string | stype () const final |
| string represent the type of the variable | |
| const std::vector< double > & | numericalDomain () const |
| returns the domain as a sequence of values | |
| void | addValue (double value) |
| add a new value to the domain size | |
| bool | isValue (double value) const |
| does this value exist in the domain ? | |
| void | changeValue (double old_value, double new_value) |
| substitute a value by another one | |
| void | eraseValue (double value) |
| erase a value from the domain of the variable | |
| void | eraseValues () |
| clear the domain of the variable | |
| std::string | closestLabel (double val) const |
| gives the value closets to val | |
Accessors / Modifiers | |
| bool | empty () const |
| std::vector< std::string > | labels () const |
| vector of labels | |
| virtual bool | isEmpirical () const |
Operators | |
| bool | operator== (const Variable &aRV) const |
| equality operator | |
Accessors / Modifiers | |
| void | setName (const std::string &theValue) |
| sets the name of the variable | |
| const std::string & | name () const |
| returns the name of the variable | |
| void | setDescription (const std::string &theValue) const |
| sets the description of the variable | |
| const std::string & | description () const |
| returns the description of the variable | |
Protected Member Functions | |
| void | copy_ (const Variable &aRV) |
| protected copy | |
Private Member Functions | |
| bool | _checkSameDomain_ (const Variable &aRV) const final |
| check the domain | |
| std::string | _generateLabel_ (double f) const |
Private Attributes | |
| std::vector< double > | _domain_ |
| the domain of the variable | |
| std::string | _name_ |
| the name of the variable | |
| std::string | _description_ |
| the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference. | |
class NumericalDiscreteVariable
The class representing discrete numerical random variables
Definition at line 62 of file numericalDiscreteVariable.h.
| gum::NumericalDiscreteVariable::NumericalDiscreteVariable | ( | const std::string & | aName, |
| const std::string & | aDesc = "" ) |
constructor
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
References domain().
Referenced by NumericalDiscreteVariable(), NumericalDiscreteVariable(), NumericalDiscreteVariable(), NumericalDiscreteVariable(), ~NumericalDiscreteVariable(), clone(), operator=(), and operator=().
| gum::NumericalDiscreteVariable::NumericalDiscreteVariable | ( | const std::string & | aName, |
| const std::string & | aDesc, | ||
| const std::vector< double > & | domain ) |
constructor assigning a domain to the variable
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
| domain | the domain (set of values) of the variable |
Definition at line 53 of file numericalDiscreteVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), NumericalDiscreteVariable(), _domain_, domain(), GUM_ERROR, gum::isfinite(), and isValue().
| gum::NumericalDiscreteVariable::NumericalDiscreteVariable | ( | const std::string & | aName, |
| const std::string & | aDesc, | ||
| double | first, | ||
| double | last, | ||
| Size | nb ) |
constructor assigning a domain to the variable
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
| first | the first value |
| last | the last value |
| nb | the number of values |
Definition at line 72 of file numericalDiscreteVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), NumericalDiscreteVariable(), _domain_, GUM_ERROR, gum::isfinite(), and gum::Variable::name().
| gum::NumericalDiscreteVariable::NumericalDiscreteVariable | ( | const NumericalDiscreteVariable & | from | ) |
Copy constructor.
| from | the variable we copy |
References NumericalDiscreteVariable().
| gum::NumericalDiscreteVariable::NumericalDiscreteVariable | ( | NumericalDiscreteVariable && | from | ) |
|
virtual |
|
finalprivatevirtual |
check the domain
this function use the assumption that the concrete type of the variable is the same as *this
Implements gum::Variable.
|
private |
| void gum::NumericalDiscreteVariable::addValue | ( | double | value | ) |
add a new value to the domain size
| DuplicateElement | is raised if the variable already contains the value |
substitute a value by another one
|
finalvirtual |
virtual copy constructor
Implements gum::DiscreteVariable.
References NumericalDiscreteVariable().
gives the index of the value closest to val
| val | the desired double |
Implements gum::DiscreteVariable.
References closestIndex().
Referenced by closestIndex().
| std::string gum::NumericalDiscreteVariable::closestLabel | ( | double | val | ) | const |
gives the value closets to val
| val | the desired value |
|
protectedinherited |
protected copy
| aRV | to be copied |
References Variable().
|
inherited |
returns the description of the variable
|
finalvirtual |
Returns the domain as a string.
Implements gum::DiscreteVariable.
Definition at line 110 of file numericalDiscreteVariable.cpp.
References _domain_, and domainSize().
Referenced by NumericalDiscreteVariable(), NumericalDiscreteVariable(), and numerical().
|
finalvirtual |
returns the domain size of the discrete random variable
Implements gum::DiscreteVariable.
References domainSize().
Referenced by domain(), and domainSize().
|
inherited |
| void gum::NumericalDiscreteVariable::eraseValue | ( | double | value | ) |
erase a value from the domain of the variable
| void gum::NumericalDiscreteVariable::eraseValues | ( | ) |
clear the domain of the variable
|
finalvirtual |
returns the index of a given label
| label | searched label |
| NotFound |
Implements gum::DiscreteVariable.
References index(), and label().
Referenced by index(), label(), and numerical().
|
inlinevirtualinherited |
Reimplemented in gum::IDiscretizedVariable.
Definition at line 124 of file discreteVariable.h.
does this value exist in the domain ?
Referenced by NumericalDiscreteVariable().
|
finalvirtual |
returns a string corresponding to the ith value of the domain
Implements gum::DiscreteVariable.
References index(), and label().
Referenced by index(), and label().
|
inherited |
vector of labels
Referenced by gum::LabelizedVariable::LabelizedVariable().
|
inherited |
returns the name of the variable
Referenced by gum::learning::IBNLearner::Database::Database(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::MultiDimImplementation< double >::MultiDimImplementation(), gum::NumericalDiscreteVariable::NumericalDiscreteVariable(), gum::BNdistance< GUM_SCALAR >::_checkCompatibility_(), gum::BayesNet< double >::_copyTensors_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveCommonType_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::BayesNetFactory< GUM_SCALAR >::_setCPTAndParents_(), gum::Instantiation::add(), gum::FMDP< double >::addCostForAction(), gum::FMDP< GUM_SCALAR >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::Estimator< GUM_SCALAR >::posterior(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::Instantiation::setValsFrom(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValuesUnchecked(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot(), gum::RangeVariable::toFast(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::varNodeListe().
get a numerical representation of the value at a given index
Implements gum::DiscreteVariable.
References domain(), index(), and numerical().
Referenced by numerical().
| const std::vector< double > & gum::NumericalDiscreteVariable::numericalDomain | ( | ) | const |
returns the domain as a sequence of values
| NumericalDiscreteVariable & gum::NumericalDiscreteVariable::operator= | ( | const NumericalDiscreteVariable & | from | ) |
copy operator
| from | the numerical discrete random variable we copy |
References NumericalDiscreteVariable().
| NumericalDiscreteVariable & gum::NumericalDiscreteVariable::operator= | ( | NumericalDiscreteVariable && | from | ) |
move operator
| from | the numerical discrete random variable we copy |
References NumericalDiscreteVariable().
|
inlineinherited |
from the label to its index in var.
| NotFound |
Definition at line 156 of file discreteVariable.h.
References index(), and label().
|
inherited |
sets the description of the variable
| theValue |
|
inherited |
sets the name of the variable
| theValue |
|
inlinefinalvirtual |
string represent the type of the variable
Implements gum::DiscreteVariable.
Definition at line 168 of file numericalDiscreteVariable.h.
References stype().
Referenced by stype().
|
finalvirtual |
returns the domain size of the discrete random variable
Implements gum::DiscreteVariable.
References toFast().
Referenced by toFast().
|
inherited |
string version of *this
Referenced by gum::IntegerVariable::IntegerVariable(), and gum::BNdistance< GUM_SCALAR >::_checkCompatibility_().
|
inherited |
string version of *this using description attribute instead of name.
|
finalvirtual |
returns the type of variable
Implements gum::DiscreteVariable.
References varType().
Referenced by varType().
|
mutableprivateinherited |
the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference.
Definition at line 165 of file variable.h.
|
private |
the domain of the variable
Definition at line 202 of file numericalDiscreteVariable.h.
Referenced by NumericalDiscreteVariable(), NumericalDiscreteVariable(), and domain().
|
privateinherited |
the name of the variable
Definition at line 160 of file variable.h.