33 namespace distributions
65 reader_->read({defaultUnits,
unitAny},
dict,
"values");
73 return a.
first() <
b.first();
78 for (
label i = 1; i < values.
size(); ++ i)
80 if (values[i].
second() < 0)
83 << typeName <<
": The probabilities are not all positive "
89 x_.resize(values.
size());
92 x_[i] = values[i].
first();
96 P_.resize(values.
size());
99 P_[i] =
integerPow(x_[i], q())*values[i].second();
107 sumP_[i + 1] = sumP_[i] + P_[i];
112 sumP_ /= sumP_.last();
123 reader_(d.reader_, false),
128 if (
q() == d.
q())
return;
138 sumP_[i + 1] = sumP_[i] + P_[i];
143 sumP_ /= sumP_.
last();
157 const scalar
S = rndGen_.sample01<scalar>();
160 for (; i < sumP_.size() - 1 && sumP_[i + 1] <
S; ++ i);
197 while (i <
x.size() &&
x[i] < x_[0])
203 scalar integral_PDFxPowE_0_j = P_[0]*
integerPow(x_[0],
e);
205 for (
label j = 0; j < x_.size() - 1; ++ j)
207 while (i <
x.size() &&
x[i] < x_[j + 1])
209 result[i] = integral_PDFxPowE_0_j;
213 integral_PDFxPowE_0_j += P_[j + 1]*
integerPow(x_[j + 1],
e);
218 result[i] = integral_PDFxPowE_0_j;
244 values[i].
first() = x_[i];
245 values[i].second() = P[i];
259 result[3*i] = result[3*i + 1] = result[3*i + 2] = x_[i];
274 result[3*i] = result[3*i + 2] = 0;
275 result[3*i + 1] = P_[i]/rootVSmall;
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Base class to read table data for tables.
A 2-tuple for storing two objects of different types.
const Type1 & first() const
Return first.
T & first()
Return the first element of the list.
T & last()
Return the last element of the list.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base class for statistical distributions.
label q() const
Return the effective distribution size exponent.
Distribution which comprises a list of fixed values with given probabilities. The probabilities are n...
multiFixedValue(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual tmp< scalarField > integralPDFxPow(const scalarField &x, const label e, const bool consistent=false) const
Return the integral of the PDF multiplied by an integer power of x.
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
virtual tmp< scalarField > plotPDF(const scalarField &x) const
Return values to plot the probability density function.
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
virtual ~multiFixedValue()
Destructor.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
virtual tmp< scalarField > plotX(const label n) const
Return coordinates to plot across the range of the distribution.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
defineTypeNameAndDebug(exponential, 0)
addToRunTimeSelectionTable(distribution, exponential, dictionary)
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const unitConversion unitAny
errorManip< error > abort(error &err)
scalar integerPow(const scalar x, const label e)
Compute the power of the number x to the integer e.
labelList second(const UList< labelPair > &p)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
randomGenerator rndGen(653213)