35 namespace distributions
54 static const scalar sqrt2Pi =
sqrt(2*
pi);
67 static const scalar sqrt2 =
sqrt(scalar(2));
68 return (1 + standardNormal::approxErf((
x - mu_)/(sigma_*sqrt2)))/2;
72 return unintegrableForNonZeroQ::Phi(q,
x);
77 Foam::scalar Foam::distributions::normal::sampleForZeroQ(
const scalar
s)
const
79 static const scalar sqrt2 =
sqrt(scalar(2));
80 const Pair<scalar>& Phi01 = this->Phi01();
81 const scalar PhiS = (1 -
s)*Phi01[0] +
s*Phi01[1];
82 return standardNormal::approxErfInv(2*PhiS - 1)*sigma_*sqrt2 + mu_;
104 min_(
dict.lookupBackwardsCompatible<scalar>({
"min",
"minValue"},
units)),
105 max_(
dict.lookupBackwardsCompatible<scalar>({
"max",
"maxValue"},
units)),
106 mu_(
dict.lookupBackwardsCompatible<scalar>({
"mu",
"expectation"},
units)),
107 sigma_(
dict.lookup<scalar>(
"sigma",
units))
109 validateBounds(
dict);
110 if (q() != 0) validatePositive(
dict);
163 return sampleForZeroQ(rndGen_.sample01<scalar>());
Macros for easy insertion into run-time selection tables.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keyword definitions, which are a keyword followed by any number of values (e....
Base class for statistical distributions.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
Normal distribution, scaled so that it spans between a specified minimum and maximum value,...
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
normal(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
virtual ~normal()
Destructor.
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
scalar sample() const
Sample the distribution.
virtual scalar mean() const
Return the mean value.
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...
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
const dimensionedScalar mu
Atomic mass unit.
defineTypeNameAndDebug(exponential, 0)
addToRunTimeSelectionTable(distribution, exponential, dictionary)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
dimensionedScalar exp(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalar integerPow(const scalar x, const label e)
Compute the power of the number x to the integer e.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensionedScalar sqrt(const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
randomGenerator rndGen(653213)