distribution Class Referenceabstract

Base class for statistical distributions. More...

Inheritance diagram for distribution:
Collaboration diagram for distribution:

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< distributionclone (const label sampleQ) const =0
 Construct and return a clone. More...
 
autoPtr< distributionclone () 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< scalarFieldsample (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< scalarFieldCDF (const scalarField &x) const
 Return the cumulative density function at the given coordinates. More...
 
virtual tmp< scalarFieldintegralPDFxPow (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< scalarFieldplotX (const label n) const
 Return coordinates to plot across the range of the distribution. More...
 
virtual tmp< scalarFieldplotPDF (const scalarField &x) const =0
 Return values to plot the probability density function. More...
 

Static Public Member Functions

static autoPtr< distributionNew (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< distributionNew (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< distributionNew (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< scalarFieldclipPDF (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...
 

Detailed Description

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":

  • If Q=0, then "proportion" means the number of sampled values expected to be below x divided by the total number of sampled values.
  • If Q=3, then "proportion" means the expected sum of sampled values cubed for values below x divided by the total sum of values cubed. If x is a length, then this can be interpreted as a proportion of the total volume of sampled objects.
  • If Q=2, and x is a length, then the distribution might represent the proportion of surface area, and so on...

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...

Source files

Definition at line 75 of file distribution.H.

Constructor & Destructor Documentation

◆ distribution() [1/3]

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_.

Here is the call graph for this function:

◆ distribution() [2/3]

distribution ( const label  Q,
const label  sampleQ,
randomGenerator &&  rndGen 
)

Construct from components.

Definition at line 105 of file distribution.C.

◆ distribution() [3/3]

distribution ( const distribution d,
const label  sampleQ 
)

Construct copy.

Definition at line 118 of file distribution.C.

◆ ~distribution()

~distribution ( )
virtual

Destructor.

Definition at line 128 of file distribution.C.

Member Function Documentation

◆ validateBounds()

void validateBounds ( const dictionary dict) const
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().

Here is the call graph for this function:

◆ validatePositive()

void validatePositive ( const dictionary dict) const
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().

Here is the call graph for this function:

◆ clipPDF()

Foam::tmp< Foam::scalarField > clipPDF ( const scalarField x,
const tmp< scalarField > &  pdf 
) const
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.

Here is the call graph for this function:

◆ q()

label q ( ) const
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().

Here is the caller graph for this function:

◆ FOR_ALL_FIELD_TYPES()

FOR_ALL_FIELD_TYPES ( VIRTUAL_SAMPLE_TYPE  )
protected

◆ TypeName()

TypeName ( "distribution"  )

Runtime type information.

◆ declareRunTimeSelectionTable()

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.

◆ clone() [1/2]

virtual autoPtr<distribution> clone ( const label  sampleQ) const
pure virtual

Construct and return a clone.

Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.

◆ clone() [2/2]

autoPtr<distribution> clone ( ) const
inline

Construct and return a clone.

Definition at line 168 of file distribution.H.

References distribution::sampleQ_.

◆ New() [1/3]

Foam::autoPtr< Foam::distribution > New ( const unitConversion units,
const dictionary dict,
const label  sampleQ,
randomGenerator &&  rndGen,
const bool  report = true 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ New() [2/3]

Foam::autoPtr< Foam::distribution > New ( const unitConversion units,
const dictionary dict,
const label  sampleQ,
const randomGenerator::seed s,
const bool  global = false,
const bool  report = true 
)
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().

Here is the call graph for this function:

◆ New() [3/3]

Foam::autoPtr< Foam::distribution > New ( autoPtr< distribution > &  dPtr,
const label  sampleQ 
)
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().

Here is the call graph for this function:

◆ sampleQ()

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().

Here is the caller graph for this function:

◆ start()

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.

◆ sample() [1/3]

◆ sample() [2/3]

Type sample ( ) const

Sample the distribution into components of a primitive type.

◆ sample() [3/3]

◆ min()

virtual scalar min ( ) const
pure virtual

Return the minimum value.

Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.

Referenced by populationBalanceModel::etaV(), and distribution::validateBounds().

Here is the caller graph for this function:

◆ max()

virtual scalar max ( ) const
pure virtual

Return the maximum value.

Implemented in uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.

Referenced by populationBalanceModel::etaV(), and distribution::validateBounds().

Here is the caller graph for this function:

◆ mean()

virtual scalar mean ( ) const
pure virtual

◆ CDF()

Foam::tmp< Foam::scalarField > CDF ( const scalarField x) const
virtual

Return the cumulative density function at the given coordinates.

Definition at line 147 of file distribution.C.

References x.

◆ integralPDFxPow()

virtual tmp<scalarField> integralPDFxPow ( const scalarField x,
const label  e,
const bool  consistent = false 
) const
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().

Here is the caller graph for this function:

◆ write()

void write ( Ostream os,
const unitConversion units 
) const
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeState()

void writeState ( Ostream os) const
virtual

Write the state to a stream.

Definition at line 160 of file distribution.C.

References Foam::writeEntry().

Referenced by Foam::writeEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plotX()

Foam::tmp< Foam::scalarField > plotX ( const label  n) const
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plotPDF()

virtual tmp<scalarField> plotPDF ( const scalarField x) const
pure virtual

Return values to plot the probability density function.

Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, multiFixedValue, and fixedValue.

Member Data Documentation

◆ Q_

const label Q_
protected

Distribution size exponent.

Definition at line 82 of file distribution.H.

Referenced by distribution::distribution(), and distribution::q().

◆ sampleQ_

const label sampleQ_
protected

Sample size exponent.

Definition at line 85 of file distribution.H.

Referenced by distribution::clone(), distribution::distribution(), and distribution::q().

◆ rndGen_

restartableRandomGenerator rndGen_
mutableprotected

Random number generator.

Definition at line 88 of file distribution.H.


The documentation for this class was generated from the following files: