45 parse(description,
true);
71 const std::string distName = description.substr(0, description.find(
'('));
72 if (distName ==
"norm" || distName ==
"normc") {
73 const std::vector<std::string> params =
StringTokenizer(description.substr(distName.size() + 1, description.size() - distName.size() - 2),
',').
getVector();
87 throw ProcessError(
TL(
"Invalid format of distribution parameterized"));
89 WRITE_ERROR(
TL(
"Invalid format of distribution parameterized"));
104 error =
TL(
"Invalid format of distribution parameterized");
113 throw ProcessError(
TL(
"Attempted to sample from dummy distribution"));
121 const double max =
getMax();
122 while (val < min || val > max) {
133 return std::numeric_limits<double>::infinity();
145 return -std::numeric_limits<double>::infinity();
181 return "Dummy Distribution (invalid)";
184 return TLF(
"minimum value % larger than maximum %",
getMin(),
getMax());
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
virtual ~Distribution_Parameterized()
Destructor.
double getMax() const
Returns the maximum value of this distribution.
double getMin() const
Returns the minimum value of this distribution.
Distribution_Parameterized()
Dummy Constructor for a default distribution.
void setParameter(const int index, const double value)
Set a parameter of this distribution.
std::string toStr(std::streamsize accuracy) const
Returns the string representation of this distribution.
static bool isValidDescription(const std::string &description, std::string &error)
validate input description
const std::string isValid() const
check whether the distribution is valid
std::vector< double > myParameter
The distribution's parameters.
double sample(SumoRNG *which=nullptr) const
Draw a sample of the distribution using the given RNG.
std::string myID
The name of the object.
virtual void setID(const std::string &newID)
resets the id
static double randNorm(double mean, double variance, SumoRNG *rng=nullptr)
Access to a random number from a normal distribution.
std::vector< std::string > getVector()
return vector of strings
static double toDoubleAllowTime(const std::string &sData)
converts a string into a double value. Values in human-readable-time format (see string2time) are per...