35 namespace distributions
65 if (values.
first().second() != 0)
68 << typeName <<
": The cumulative distribution function does not "
72 for (
label i = 1; i < values.
size(); ++ i)
74 if (values[i].
first() - values[i - 1].
first() < 0)
77 << typeName <<
": The cumulative distribution function is not "
84 << typeName <<
": The cumulative distribution function is not "
103 for (
label i = 1; i < values.
size(); ++ i)
108 *(values[i].second() - values[i - 1].second());
118 PDF_[i] = (CDF_[i + 1] - CDF_[i])/(x_[i + 1] - x_[i]);
139 if (
q() == d.
q())
return;
148 *(d.CDF_[i] - d.CDF_[i - 1]);
155 PDF_[i] = (CDF_[i + 1] - CDF_[i])/(x_[i + 1] - x_[i]);
204 for (
label i = 1; i < CDF_.size(); ++ i)
209 *(CDF_[i] - CDF_[i - 1]);
220 values[i].second() = CDF[i];
231 const scalar x0 =
min(), x1 =
max(), d = 0.1*(x1 - x0);
236 result[0] =
Foam::max(x0 - d, q() < 0 ? x0/2 : rootVSmall);
240 result[2*i + 1] = result[2*i + 2] = x_[i];
243 result[2*x_.size() + 1] = x1 + d;
255 result[0] = result[1] = 0;
259 result[2*i + 2] = result[2*i + 3] = PDF_[i];
262 result[2*PDF_.size() + 2] = result[2*PDF_.size() + 3] = 0;
#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,...
T & first()
Return the first element of the list.
T & last()
Return the last element of the list.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Base class for statistical distributions.
virtual void validatePositive(const dictionary &dict) const
Validate that the lower bound is positive.
label q() const
Return the effective distribution size exponent.
virtual void validateBounds(const dictionary &dict) const
Validate that the bounds are monotonic.
Distribution in which the cumulative distribution function is given as a table of values.
virtual ~tabulatedCumulative()
Destructor.
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
virtual tmp< scalarField > PDF(const scalarField &x) const
Return the distribution probability density function.
tabulatedCumulative(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
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.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
#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)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
randomGenerator rndGen(653213)