35 namespace distributions
77 if (i && values[i].
first() - values[i - 1].
first() < 0)
80 <<
typeName <<
": The probability density function is not "
84 if (values[i].
second() < 0)
87 <<
typeName <<
": The probability density function is not "
93 x_.resize(values.
size());
96 x_[i] = values[i].
first();
100 PDF_.resize(values.
size());
103 PDF_[i] =
integerPow(x_[i], q())*values[i].second();
115 validateBounds(
dict);
116 if (q() != 0) validatePositive(
dict);
127 reader_(d.reader_, false),
132 if (
q() == d.
q())
return;
208 values[i].
first() = x_[i];
209 values[i].second() = PDF[i];
211 reader_->write(os, {units,
units::any}, values,
"distribution");
218 const scalar x0 =
min(), x1 =
max(), d = 0.1*(x1 - x0);
223 result[0] =
Foam::max(x0 - d, q() < 0 ? x0/2 : rootVSmall);
228 result[x_.size() + 2] = x1;
229 result[x_.size() + 3] = x1 + d;
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Pre-declare related SubField type.
Base class to read table data for tables.
T & first()
Return the first element of the list.
T & last()
Return the last element of the list.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base class for statistical distributions.
label q() const
Return the effective distribution size exponent.
Distribution in which the probability density function is given as a table of values.
virtual tmp< scalarField > integralPDFxPow(const scalarField &x, const label e, const bool consistent=false) const
Return the integral of the PDF multiplied by an integer power of x.
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
tabulatedDensity(const unitSet &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual tmp< scalarField > plotPDF(const scalarField &x) const
Return values to plot the probability density function.
virtual void write(Ostream &os, const unitSet &units) const
Write to a stream.
virtual ~tabulatedDensity()
Destructor.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
virtual tmp< scalarField > plotX(const label n) const
Return coordinates to plot across the range of the distribution.
virtual scalar sample() const
Sample the distribution.
static tmp< scalarField > integrate(const scalarField &x, const scalarField &y)
Integrate the values y with respect to the coordinates x.
static tmp< scalarField > integrateX(const scalarField &x, const scalarField &y)
Integrate the values x*y with respect to the coordinates x.
static tmp< scalarField > interpolateIntegrateXPow(const scalarField &xStar, const label e, const scalarField &yStar, const scalarField &x)
Integrate the values x^e*y with respect to the coordinates x,.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
defineTypeNameAndDebug(exponential, 0)
addToRunTimeSelectionTable(distribution, exponential, dictionary)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManip< error > abort(error &err)
scalar integerPow(const scalar x, const label e)
Compute the power of the number x to the integer e.
labelList second(const UList< labelPair > &p)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList first(const UList< labelPair > &p)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
randomGenerator rndGen(653213)