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... | |
label | sampleQ () const |
Access the sample size exponent. More... | |
void | start (const bool repeat) const |
Start a sequence of samples. Either a new sequence, or a. 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 tmp< scalarField > | CDF (const scalarField &x) const |
Return the cumulative density function at the given coordinates. More... | |
virtual tmp< scalarField > | integralPDFxPow (const scalarField &x, const label e, const bool consistent=false) const =0 |
Return the integral of the PDF multiplied by an integer power of x. 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 > | plotX (const label n) const |
Return coordinates to plot across the range of the distribution. More... | |
virtual tmp< scalarField > | plotPDF (const scalarField &x) const =0 |
Return values to plot the 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... | |
restartableRandomGenerator | 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().
|
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().
|
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 multiFixedValue::multiFixedValue(), unintegrableForNonZeroQ::Phi(), tabulatedCumulative::tabulatedCumulative(), tabulatedDensity::tabulatedDensity(), and unintegrable::unintegrable().
|
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, multiFixedValue, 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::FatalIOError, FatalIOErrorInFunction, Foam::incrIndent(), Foam::indent(), Foam::Info, Foam::nl, rndGen(), distribution::sampleQ(), and Foam::units().
Referenced by distributionDiameterLagrangianScalarFieldSource::value().
|
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().
Foam::label sampleQ | ( | ) | const |
Access the sample size exponent.
Definition at line 134 of file distribution.C.
Referenced by fixedValue::clone(), multiFixedValue::clone(), tabulatedCumulative::clone(), tabulatedDensity::clone(), uniform::clone(), populationBalanceModel::etaV(), and distribution::New().
void start | ( | const bool | repeat | ) | const |
Start a sequence of samples. Either a new sequence, or a.
repeat of the previous, as indicated by the provided flag.
Definition at line 140 of file distribution.C.
|
pure virtual |
Sample the distribution.
Implemented in unintegrableForNonZeroQ, unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, fixedValue, FieldDistribution< distribution, fixedValue >, FieldDistribution< distribution, multiFixedValue >, 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, multiFixedValue >, 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, multiFixedValue, and fixedValue.
Referenced by populationBalanceModel::etaV(), and distribution::validateBounds().
|
pure virtual |
Return the maximum value.
Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.
Referenced by populationBalanceModel::etaV(), and distribution::validateBounds().
|
pure virtual |
Return the mean value.
Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.
|
virtual |
Return the cumulative density function at the given coordinates.
Definition at line 147 of file distribution.C.
References x.
|
pure virtual |
Return the integral of the PDF multiplied by an integer power of x.
If the power given is zero then this generates the CDF. The consistent flag disables analytical overrides to ensure that numerical evaluations with different x or e arguments are evaluated by the same process and are therefore consistent with each other. This should be used if multiple evaluations are being made and the results combined.
Implemented in unintegrableForNonZeroQ, unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.
Referenced by populationBalanceModel::etaV().
|
virtual |
Write to a stream.
Reimplemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, multiFixedValue, and fixedValue.
Definition at line 153 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 160 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, multiFixedValue, and fixedValue.
Definition at line 166 of file distribution.C.
References f(), Foam::max(), Foam::min(), n, tmp< T >::ref(), and Foam::sign().
Referenced by exponential::plotX(), normal::plotX(), and RosinRammler::plotX().
|
pure virtual |
Return values to plot the probability density function.
Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, 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.