Base class for statistical distributions. More...
Public Member Functions | |
TypeName ("distribution") | |
Runtime type information. More... | |
declareRunTimeSelectionTable (autoPtr, distribution, dictionary,(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen),(units, dict, sampleQ, std::move(rndGen))) | |
Declare runtime constructor selection table. More... | |
distribution (const word &name, const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen) | |
Construct from dictionary. More... | |
distribution (const label Q, const label sampleQ, randomGenerator &&rndGen) | |
Construct from components. More... | |
distribution (const distribution &d, const label sampleQ) | |
Construct copy. More... | |
virtual autoPtr< distribution > | clone (const label sampleQ) const =0 |
Construct and return a clone. More... | |
autoPtr< distribution > | clone () const |
Construct and return a clone. More... | |
virtual | ~distribution () |
Destructor. More... | |
virtual scalar | sample () const =0 |
Sample the distribution. More... | |
template<class Type > | |
Type | sample () const |
Sample the distribution into components of a primitive type. More... | |
virtual tmp< scalarField > | sample (const label n) const =0 |
Sample the distribution into a field. More... | |
virtual scalar | min () const =0 |
Return the minimum value. More... | |
virtual scalar | max () const =0 |
Return the maximum value. More... | |
virtual scalar | mean () const =0 |
Return the mean value. More... | |
virtual void | write (Ostream &os, const unitConversion &units) const |
Write to a stream. More... | |
virtual void | writeState (Ostream &os) const |
Write the state to a stream. More... | |
virtual tmp< scalarField > | x (const label n) const |
Return coordinates to plot across the range of the distribution. More... | |
virtual tmp< scalarField > | PDF (const scalarField &x) const =0 |
Return the distribution probability density function. More... | |
Static Public Member Functions | |
static autoPtr< distribution > | New (const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen, const bool report=true) |
Select from dictionary and a random generator. More... | |
static autoPtr< distribution > | New (const unitConversion &units, const dictionary &dict, const label sampleQ, const randomGenerator::seed &s, const bool global=false, const bool report=true) |
Select from a dictionary and a random generator seed and global flag. More... | |
static autoPtr< distribution > | New (autoPtr< distribution > &dPtr, const label sampleQ) |
Re-select with a different sample size exponent. More... | |
Protected Member Functions | |
virtual void | validateBounds (const dictionary &dict) const |
Validate that the bounds are monotonic. More... | |
virtual void | validatePositive (const dictionary &dict) const |
Validate that the lower bound is positive. More... | |
tmp< scalarField > | clipPDF (const scalarField &x, const tmp< scalarField > &pdf) const |
Clip the PDF values to zero outside the bounds. More... | |
label | q () const |
Return the effective distribution size exponent. More... | |
FOR_ALL_FIELD_TYPES (VIRTUAL_SAMPLE_TYPE) | |
Protected Attributes | |
const label | Q_ |
Distribution size exponent. More... | |
const label | sampleQ_ |
Sample size exponent. More... | |
randomGenerator | rndGen_ |
Random number generator. More... | |
Base class for statistical distributions.
All distributions (except fixedValue) require a "size exponent", Q, to be specified along with their other coefficients. If a distribution's CDF(x) (cumulative distribution function) represents what proportion of the distribution takes a value below x, then Q determines what is meant by "proportion":
In addition to the user-specification of Q defining what size the given distribution relates to, an implementation that uses a distribution can also programmatically define a samplingQ to determine what sort of sample is being constructed; whether the samples should have an equal number (sampleQ=0), volume (sampleQ=3), area (sampleQ=2), etc...
Definition at line 75 of file distribution.H.
distribution | ( | const word & | name, |
const unitConversion & | units, | ||
const dictionary & | dict, | ||
const label | sampleQ, | ||
randomGenerator && | rndGen | ||
) |
Construct from dictionary.
Definition at line 76 of file distribution.C.
References Foam::abort(), dict, Foam::FatalError, FatalErrorInFunction, Foam::FatalIOError, FatalIOErrorInFunction, Foam::name(), Foam::nl, distribution::Q_, and distribution::sampleQ_.
distribution | ( | const label | Q, |
const label | sampleQ, | ||
randomGenerator && | rndGen | ||
) |
Construct from components.
Definition at line 105 of file distribution.C.
distribution | ( | const distribution & | d, |
const label | sampleQ | ||
) |
Construct copy.
Definition at line 118 of file distribution.C.
|
virtual |
Destructor.
Definition at line 128 of file distribution.C.
|
protectedvirtual |
Validate that the bounds are monotonic.
Definition at line 39 of file distribution.C.
References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, distribution::max(), distribution::min(), Foam::nl, and Foam::type().
Referenced by tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().
|
protectedvirtual |
Validate that the lower bound is positive.
Definition at line 51 of file distribution.C.
References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, Foam::min(), Foam::nl, and Foam::type().
Referenced by tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().
|
protected |
Clip the PDF values to zero outside the bounds.
Definition at line 64 of file distribution.C.
References Foam::max(), Foam::min(), Foam::pos0(), and x.
|
inlineprotected |
Return the effective distribution size exponent.
Definition at line 107 of file distribution.H.
References distribution::Q_, and distribution::sampleQ_.
Referenced by tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().
|
protected |
TypeName | ( | "distribution" | ) |
Runtime type information.
declareRunTimeSelectionTable | ( | autoPtr | , |
distribution | , | ||
dictionary | , | ||
(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen) | , | ||
(units, dict, sampleQ, std::move(rndGen)) | |||
) |
Declare runtime constructor selection table.
|
pure virtual |
Construct and return a clone.
Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
|
inline |
Construct and return a clone.
Definition at line 168 of file distribution.H.
References distribution::sampleQ_.
|
static |
Select from dictionary and a random generator.
Definition at line 30 of file distributionNew.C.
References Foam::decrIndent(), dict, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::incrIndent(), Foam::indent(), Foam::Info, Foam::nl, rndGen(), and Foam::units().
|
static |
Select from a dictionary and a random generator seed and global flag.
Definition at line 83 of file distributionNew.C.
References dict, Foam::New(), s(), and Foam::units().
|
static |
Re-select with a different sample size exponent.
Definition at line 97 of file distributionNew.C.
References autoPtr< T >::clear(), and autoPtr< T >::ptr().
|
pure virtual |
Sample the distribution.
Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, fixedValue, FieldDistribution< distribution, fixedValue >, FieldDistribution< distribution, tabulatedCumulative >, FieldDistribution< distribution, standardNormal >, FieldDistribution< distribution, uniform >, and FieldDistribution< distribution, tabulatedDensity >.
Type sample | ( | ) | const |
Sample the distribution into components of a primitive type.
|
pure virtual |
Sample the distribution into a field.
Implemented in FieldDistribution< distribution, fixedValue >, FieldDistribution< distribution, tabulatedCumulative >, FieldDistribution< distribution, standardNormal >, FieldDistribution< distribution, uniform >, and FieldDistribution< distribution, tabulatedDensity >.
|
pure virtual |
Return the minimum value.
Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
Referenced by distribution::validateBounds().
|
pure virtual |
Return the maximum value.
Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
Referenced by distribution::validateBounds().
|
pure virtual |
Return the mean value.
Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
|
virtual |
Write to a stream.
Reimplemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, and fixedValue.
Definition at line 134 of file distribution.C.
References Foam::type(), and Foam::writeEntry().
Referenced by uniform::write(), unintegrable::write(), and Foam::writeEntry().
|
virtual |
Write the state to a stream.
Definition at line 141 of file distribution.C.
References Foam::writeEntry().
Referenced by Foam::writeEntry().
|
virtual |
Return coordinates to plot across the range of the distribution.
Reimplemented in tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
Definition at line 147 of file distribution.C.
References f(), Foam::max(), Foam::min(), n, tmp< T >::ref(), and Foam::sign().
Referenced by exponential::x(), normal::x(), and RosinRammler::x().
|
pure virtual |
Return the distribution probability density function.
Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, and fixedValue.
|
protected |
Distribution size exponent.
Definition at line 82 of file distribution.H.
Referenced by distribution::distribution(), and distribution::q().
|
protected |
Sample size exponent.
Definition at line 85 of file distribution.H.
Referenced by distribution::clone(), distribution::distribution(), and distribution::q().
|
mutableprotected |
Random number generator.
Definition at line 88 of file distribution.H.