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...
 
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 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< scalarFieldx (const label n) const
 Return coordinates to plot across the range of the distribution. More...
 
virtual tmp< scalarFieldPDF (const scalarField &x) const =0
 Return the distribution 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...
 
randomGenerator 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().

Referenced by tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().

Here is the call graph for this function:
Here is the caller 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().

Referenced by tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().

Here is the call graph for this function:
Here is the caller 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 tabulatedCumulative::tabulatedCumulative(), and tabulatedDensity::tabulatedDensity().

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, 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::FatalError, FatalErrorInFunction, Foam::incrIndent(), Foam::indent(), Foam::Info, Foam::nl, rndGen(), and Foam::units().

Here is the call 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:

◆ 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, and fixedValue.

Referenced by 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, and fixedValue.

Referenced by distribution::validateBounds().

Here is the caller graph for this function:

◆ mean()

virtual scalar mean ( ) const
pure virtual

Return the mean value.

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

◆ write()

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

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

◆ x()

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

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

◆ PDF()

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

Return the distribution probability density function.

Implemented in unintegrable, uniform, tabulatedDensity, tabulatedCumulative, standardNormal, 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_

randomGenerator rndGen_
mutableprotected

Random number generator.

Definition at line 88 of file distribution.H.


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