distribution Class Referenceabstract

Accumulating histogram of values. Specified bin resolution automatic generation of bins. More...

Inheritance diagram for distribution:
Collaboration diagram for distribution:

Public Member Functions

 TypeName ("distribution")
 Runtime type information. More...
 
 distribution ()
 Construct null. More...
 
 distribution (const scalar binWidth)
 Construct from binWidth. More...
 
 distribution (const distribution &)
 Copy constructor. More...
 
virtual ~distribution ()
 Destructor. More...
 
label totalEntries () const
 
scalar approxTotalEntries () const
 
scalar mean () const
 
scalar median ()
 
void add (const scalar valueToAdd)
 Add a value to the appropriate bin of the distribution. More...
 
void add (const label valueToAdd)
 
void insertMissingKeys ()
 
List< Pair< scalar > > normalised ()
 
List< Pair< scalar > > normalisedMinusMean ()
 
List< Pair< scalar > > normalisedShifted (scalar shiftValue)
 
List< Pair< scalar > > raw ()
 
scalar binWidth () const
 
void operator= (const distribution &)
 
 TypeName ("distribution")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, distribution, dictionary,(const dictionary &dict, Random &rndGen, const label sampleQ),(dict, rndGen, sampleQ))
 Declare runtime constructor selection table. More...
 
 distribution (const word &name, const dictionary &dict, Random &rndGen, const label sampleQ)
 Construct from dictionary. More...
 
 distribution (Random &rndGen, const label Q, const label sampleQ)
 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...
 
virtual tmp< scalarFieldsample (const label n) const =0
 Sample the distribution. 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...
 
void report () const
 Report. 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...
 
- Public Member Functions inherited from Map< label >
 Map (const label size=128)
 Construct given initial size. More...
 
 Map (Istream &is)
 Construct from Istream. More...
 
 Map (const Map< label > &map)
 Copy constructor. More...
 
 Map (Map< label > &&map)
 Move constructor. More...
 
 Map (HashTable< label, label, Hash< label >> &&map)
 Move constructor. More...
 
 Map (std::initializer_list< Tuple2< label, label >> map)
 Construct from an initialiser list. More...
 
void operator= (const Map< label > &map)
 
void operator= (Map< label > &&map)
 
- Public Member Functions inherited from HashTable< T, Key, Hash >
 HashTable (const label size=128)
 Construct given initial table size. More...
 
 HashTable (Istream &, const label size=128)
 Construct from Istream. More...
 
 HashTable (const HashTable< T, Key, Hash > &)
 Copy constructor. More...
 
 HashTable (HashTable< T, Key, Hash > &&)
 Move constructor. More...
 
 HashTable (std::initializer_list< Tuple2< Key, T >>)
 Construct from an initialiser list. More...
 
 ~HashTable ()
 Destructor. More...
 
label capacity () const
 The size of the underlying table. More...
 
label size () const
 Return number of elements in table. More...
 
bool empty () const
 Return true if the hash table is empty. More...
 
bool found (const Key &) const
 Return true if hashedEntry is found in table. More...
 
iterator find (const Key &)
 Find and return an iterator set at the hashedEntry. More...
 
const_iterator find (const Key &) const
 Find and return an const_iterator set at the hashedEntry. More...
 
List< Key > toc () const
 Return the table of contents. More...
 
List< Key > sortedToc () const
 Return the table of contents as a sorted list. More...
 
OstreamprintInfo (Ostream &) const
 Print information. More...
 
bool insert (const Key &, const T &newElmt)
 Insert a new hashedEntry. More...
 
bool set (const Key &, const T &newElmt)
 Assign a new hashedEntry, overwriting existing entries. More...
 
bool erase (const iterator &)
 Erase a hashedEntry specified by given iterator. More...
 
bool erase (const Key &)
 Erase a hashedEntry specified by the given key. More...
 
label erase (const UList< Key > &)
 Remove entries given by the listed keys from this HashTable. More...
 
template<class AnyType , class AnyHash >
label erase (const HashTable< AnyType, Key, AnyHash > &)
 Remove entries given by the given keys from this HashTable. More...
 
void resize (const label newSize)
 Resize the hash table for efficiency. More...
 
void clear ()
 Clear all entries from table. More...
 
void clearStorage ()
 Clear the table entries and the table itself. More...
 
void shrink ()
 Shrink the allocated table to approx. twice number of elements. More...
 
void transfer (HashTable< T, Key, Hash > &)
 Transfer the contents of the argument table into this table. More...
 
Toperator[] (const Key &)
 Find and return a hashedEntry. More...
 
const Toperator[] (const Key &) const
 Find and return a hashedEntry. More...
 
Toperator() (const Key &)
 Find and return a hashedEntry, create it null if not present. More...
 
void operator= (const HashTable< T, Key, Hash > &)
 Assignment operator. More...
 
void operator= (HashTable< T, Key, Hash > &&)
 Move assignment operator. More...
 
void operator= (std::initializer_list< Tuple2< Key, T >>)
 Assignment to an initialiser list. More...
 
bool operator== (const HashTable< T, Key, Hash > &) const
 Equality. Hash tables are equal if the keys and values are equal. More...
 
bool operator!= (const HashTable< T, Key, Hash > &) const
 The opposite of the equality operation. Takes linear time. More...
 
iterator begin ()
 Iterator set to the beginning of the HashTable. More...
 
const_iterator cbegin () const
 const_iterator set to the beginning of the HashTable More...
 
const_iterator begin () const
 const_iterator set to the beginning of the HashTable More...
 
template<class AnyType , class AnyHash >
Foam::label erase (const HashTable< AnyType, Key, AnyHash > &rhs)
 
- Public Member Functions inherited from HashTableCore
 HashTableCore ()
 Construct null. More...
 
 ClassName ("HashTable")
 Define template name and debug. More...
 

Static Public Member Functions

static void write (const fileName &file, const List< Pair< scalar >> &pairs)
 Write to file. More...
 
static autoPtr< distributionNew (const dictionary &dict, Random &rndGen, const label sampleQ)
 Selector. More...
 
- Static Public Member Functions inherited from HashTableCore
static label canonicalSize (const label)
 Return a canonical (power-of-two) size. More...
 
static iteratorEnd cend ()
 iteratorEnd set to beyond the end of any HashTable More...
 
static iteratorEnd end ()
 iteratorEnd set to beyond the end of any HashTable 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...
 

Protected Attributes

RandomrndGen_
 Reference to a random number generator. More...
 
const label Q_
 Distribution size exponent. More...
 
const label sampleQ_
 Sample size exponent. More...
 

Friends

Ostreamoperator<< (Ostream &, const distribution &)
 

Additional Inherited Members

- Public Types inherited from Map< label >
typedef HashTable< label, label, Hash< label > >::iterator iterator
 
typedef HashTable< label, label, Hash< label > >::const_iterator const_iterator
 
- Public Types inherited from HashTable< T, Key, Hash >
typedef T value_type
 Type of values the HashTable contains. More...
 
typedef Treference
 Type that can be used for storing into HashTable::value_type. More...
 
typedef const Tconst_reference
 Type that can be used for storing into constant. More...
 
typedef label size_type
 The type that can represent the size of a HashTable. More...
 
- Static Public Attributes inherited from HashTableCore
static const label maxTableSize
 Maximum allowable table size. More...
 

Detailed Description

Accumulating histogram of values. Specified bin resolution automatic generation of bins.

Base class for statistical distributions.

Source files

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 58 of file distribution.H.

Constructor & Destructor Documentation

◆ distribution() [1/6]

Construct null.

Definition at line 55 of file distribution.C.

◆ distribution() [2/6]

distribution ( const scalar  binWidth)

Construct from binWidth.

Definition at line 62 of file distribution.C.

◆ distribution() [3/6]

distribution ( const distribution d)

Copy constructor.

Definition at line 69 of file distribution.C.

◆ ~distribution() [1/2]

~distribution ( )
virtual

Destructor.

Definition at line 78 of file distribution.C.

◆ distribution() [4/6]

distribution ( const word name,
const dictionary dict,
Random rndGen,
const label  sampleQ 
)

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() [5/6]

distribution ( Random rndGen,
const label  Q,
const label  sampleQ 
)

Construct from components.

Definition at line 104 of file distribution.C.

◆ distribution() [6/6]

distribution ( const distribution d,
const label  sampleQ 
)

Construct copy.

Definition at line 117 of file distribution.C.

◆ ~distribution() [2/2]

virtual ~distribution ( )
virtual

Destructor.

Member Function Documentation

◆ TypeName() [1/2]

TypeName ( "distribution"  )

Runtime type information.

◆ write()

void write ( const fileName file,
const List< Pair< scalar >> &  pairs 
)
static

Write to file.

Definition at line 38 of file distribution.C.

References Foam::file, forAll, and Foam::nl.

◆ totalEntries()

Foam::label totalEntries ( ) const

Definition at line 84 of file distribution.C.

References Foam::endl(), forAllConstIter, and WarningInFunction.

Here is the call graph for this function:

◆ approxTotalEntries()

Foam::scalar approxTotalEntries ( ) const

Definition at line 112 of file distribution.C.

References forAllConstIter.

◆ mean() [1/2]

Foam::scalar mean ( ) const

Definition at line 125 of file distribution.C.

References forAll, and k.

◆ median()

Foam::scalar median ( )

Definition at line 148 of file distribution.C.

References UList< T >::first(), forAll, Foam::normalised(), Foam::second(), and List< T >::size().

Here is the call graph for this function:

◆ add() [1/2]

void add ( const scalar  valueToAdd)

Add a value to the appropriate bin of the distribution.

Definition at line 212 of file distribution.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::vtkWriteOps::insert(), n, and Foam::neg().

Here is the call graph for this function:

◆ add() [2/2]

void add ( const label  valueToAdd)

Definition at line 242 of file distribution.C.

References Foam::add().

Here is the call graph for this function:

◆ insertMissingKeys()

void insertMissingKeys ( )

Definition at line 248 of file distribution.C.

References Foam::vtkWriteOps::insert(), k, UList< T >::last(), List< T >::size(), and Foam::sort().

Here is the call graph for this function:

◆ normalised()

Foam::List< Foam::Pair< Foam::scalar > > normalised ( )

Definition at line 271 of file distribution.C.

References Foam::endl(), UList< T >::first(), forAll, Foam::Info, k, and Foam::sort().

Here is the call graph for this function:

◆ normalisedMinusMean()

Foam::List< Foam::Pair< Foam::scalar > > normalisedMinusMean ( )

Definition at line 301 of file distribution.C.

◆ normalisedShifted()

Foam::List< Foam::Pair< Foam::scalar > > normalisedShifted ( scalar  shiftValue)

Definition at line 307 of file distribution.C.

References Foam::endl(), UList< T >::first(), forAll, Foam::Info, Foam::nl, Foam::normalised(), Foam::second(), Foam::sign(), and List< T >::size().

Here is the call graph for this function:

◆ raw()

Foam::List< Foam::Pair< Foam::scalar > > raw ( )

Definition at line 419 of file distribution.C.

References UList< T >::first(), forAll, k, and Foam::sort().

Here is the call graph for this function:

◆ binWidth()

Foam::scalar binWidth ( ) const
inline

Definition at line 28 of file distributionI.H.

Referenced by distribution::operator=().

Here is the caller graph for this function:

◆ operator=()

void operator= ( const distribution rhs)

Definition at line 444 of file distribution.C.

References Foam::abort(), distribution::binWidth(), Foam::FatalError, FatalErrorInFunction, and Map< T >::operator=().

Here is the call graph for this function:

◆ 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 106 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:

◆ TypeName() [2/2]

TypeName ( "distribution"  )

Runtime type information.

◆ declareRunTimeSelectionTable()

declareRunTimeSelectionTable ( autoPtr  ,
distribution  ,
dictionary  ,
(const dictionary &dict, Random &rndGen, const label sampleQ)  ,
(dict, rndGen, sampleQ)   
)

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

◆ clone() [2/2]

autoPtr<distribution> clone ( ) const
inline

Construct and return a clone.

Definition at line 154 of file distribution.H.

References distribution::sampleQ_.

◆ New()

Foam::autoPtr< Foam::distribution > New ( const dictionary dict,
Random rndGen,
const label  sampleQ 
)
static

Selector.

Definition at line 30 of file distributionNew.C.

References Foam::decrIndent(), dict, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::incrIndent(), Foam::Info, Foam::nl, and rndGen().

Here is the call graph for this function:

◆ sample() [1/2]

virtual scalar sample ( ) const
pure virtual

Sample the distribution.

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

◆ sample() [2/2]

◆ min()

virtual scalar min ( ) const
pure virtual

Return the minimum value.

Implemented in uniform, tabulatedDensity, tabulatedCumulative, 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, and fixedValue.

Referenced by distribution::validateBounds().

Here is the caller graph for this function:

◆ mean() [2/2]

virtual scalar mean ( ) const
pure virtual

Return the mean value.

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

◆ report()

void report ( ) const

Report.

Definition at line 133 of file distribution.C.

References Foam::endl(), Foam::indent(), Foam::Info, Foam::max(), and Foam::min().

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

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

Definition at line 140 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, and fixedValue.

Friends And Related Function Documentation

◆ operator<<

Ostream& operator<< ( Ostream ,
const distribution  
)
friend

Member Data Documentation

◆ rndGen_

Random& rndGen_
protected

Reference to a random number generator.

Definition at line 81 of file distribution.H.

◆ Q_

const label Q_
protected

Distribution size exponent.

Definition at line 84 of file distribution.H.

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

◆ sampleQ_

const label sampleQ_
protected

Sample size exponent.

Definition at line 87 of file distribution.H.

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


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