54 std::string_view aDesc,
55 const std::vector< double >&
domain) :
59 for (
const auto value:
domain) {
73 std::string_view aDesc,
92 const double step = (last - first) / (
double(nb) - 1);
93 const double mask = std::pow(10, std::max(4,
int(2 + std::abs(-std::log10(step)))));
94 double current = first;
97 for (
Idx i = 1; i < nb - 1; i++) {
99 _domain_.push_back((std::round(current * mask) / mask));
114 s += std::format(
"{}",
_domain_[0]);
115 for (
Idx i = 1; i < size; ++i)
116 s += std::format(
"|{}",
_domain_[i]);
Exception base for argument error.
Exception : default in label.
DiscreteVariable(std::string_view aName, std::string_view aDesc)
Default constructor.
Size domainSize() const final
returns the domain size of the discrete random variable
std::string domain() const final
Returns the domain as a string.
NumericalDiscreteVariable(std::string_view aName, std::string_view aDesc="")
constructor
bool isValue(double value) const
does this value exist in the domain ?
std::vector< double > _domain_
the domain of the variable
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
gum is the global namespace for all aGrUM entities
Base class for numerical discrete random variables.
Base class for NumericalDiscrete discrete random variables.