www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
TruncatedNormalDistribution Class Reference

A class used to generate a truncated normal distribution. More...

#include <TruncatedNormalDistribution.h>

Inheritance diagram for TruncatedNormalDistribution:
[legend]

Public Member Functions

 TruncatedNormalDistribution (const InputParameters &parameters)
 
virtual Real pdf (const Real &x) const override
 
virtual Real cdf (const Real &x) const override
 
virtual Real quantile (const Real &p) const override
 
Real pdf (const Real &x, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound) const
 
Real cdf (const Real &x, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound) const
 
Real quantile (const Real &p, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound) const
 
Real pdf (const Real &x, const Real &mean, const Real &std_dev) const
 
Real cdf (const Real &x, const Real &mean, const Real &std_dev) const
 
Real quantile (const Real &p, const Real &mean, const Real &std_dev) const
 

Protected Attributes

const Real & _lower_bound
 The lower bound for the distribution. More...
 
const Real & _upper_bound
 The upper bound for the distribution. More...
 
const Real & _mean
 The mean (or expectation) of the distribution (mu) More...
 
const Real & _standard_deviation
 The standard deviation of the distribution (sigma) More...
 
const std::vector< Real > _a
 
const std::vector< Real > _b
 

Detailed Description

A class used to generate a truncated normal distribution.

Definition at line 23 of file TruncatedNormalDistribution.h.

Constructor & Destructor Documentation

◆ TruncatedNormalDistribution()

TruncatedNormalDistribution::TruncatedNormalDistribution ( const InputParameters &  parameters)

Definition at line 27 of file TruncatedNormalDistribution.C.

28  : NormalDistribution(parameters),
29  _lower_bound(getParam<Real>("lower_bound")),
30  _upper_bound(getParam<Real>("upper_bound"))
31 {
33  mooseError("lower_bound in truncated normal distribution must be less than upper_bound.");
34 }
const Real & _upper_bound
The upper bound for the distribution.
const Real & _lower_bound
The lower bound for the distribution.
NormalDistribution(const InputParameters &parameters)

Member Function Documentation

◆ cdf() [1/3]

Real TruncatedNormalDistribution::cdf ( const Real &  x) const
overridevirtual

Reimplemented from NormalDistribution.

Definition at line 89 of file TruncatedNormalDistribution.C.

90 {
92 }
const Real & _upper_bound
The upper bound for the distribution.
const Real & _lower_bound
The lower bound for the distribution.
const Real & _standard_deviation
The standard deviation of the distribution (sigma)
const Real & _mean
The mean (or expectation) of the distribution (mu)
virtual Real cdf(const Real &x) const override

◆ cdf() [2/3]

Real NormalDistribution::cdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev 
) const
inherited

Definition at line 42 of file NormalDistribution.C.

43 {
44  return 0.5 * (1.0 + std::erf((x - mean) / (std_dev * std::sqrt(2.0))));
45 }

◆ cdf() [3/3]

Real TruncatedNormalDistribution::cdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 52 of file TruncatedNormalDistribution.C.

57 {
58 
59  if (x <= lower_bound || x >= upper_bound)
60  return 0.0;
61  else
62  return (NormalDistribution::cdf(x, mean, std_dev) -
63  NormalDistribution::cdf(lower_bound, mean, std_dev)) /
64  (NormalDistribution::cdf(upper_bound, mean, std_dev) -
65  NormalDistribution::cdf(lower_bound, mean, std_dev));
66 }
virtual Real cdf(const Real &x) const override

◆ pdf() [1/3]

Real TruncatedNormalDistribution::pdf ( const Real &  x) const
overridevirtual

Reimplemented from NormalDistribution.

Definition at line 83 of file TruncatedNormalDistribution.C.

84 {
86 }
virtual Real pdf(const Real &x) const override
const Real & _upper_bound
The upper bound for the distribution.
const Real & _lower_bound
The lower bound for the distribution.
const Real & _standard_deviation
The standard deviation of the distribution (sigma)
const Real & _mean
The mean (or expectation) of the distribution (mu)

◆ pdf() [2/3]

Real TruncatedNormalDistribution::pdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 37 of file TruncatedNormalDistribution.C.

42 {
43  if (x <= lower_bound || x >= upper_bound)
44  return 0.0;
45  else
46  return (NormalDistribution::pdf(x, mean, std_dev)) /
47  (NormalDistribution::cdf(upper_bound, mean, std_dev) -
48  NormalDistribution::cdf(lower_bound, mean, std_dev));
49 }
virtual Real cdf(const Real &x) const override
virtual Real pdf(const Real &x) const override

◆ pdf() [3/3]

Real NormalDistribution::pdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev 
) const
inherited

Definition at line 35 of file NormalDistribution.C.

36 {
37  return 1.0 / (std_dev * std::sqrt(2.0 * M_PI)) *
38  std::exp(-0.5 * Utility::pow<2>((x - mean) / std_dev));
39 }

◆ quantile() [1/3]

Real TruncatedNormalDistribution::quantile ( const Real &  p) const
overridevirtual

Reimplemented from NormalDistribution.

Definition at line 95 of file TruncatedNormalDistribution.C.

96 {
98 }
const Real & _upper_bound
The upper bound for the distribution.
const Real & _lower_bound
The lower bound for the distribution.
const Real & _standard_deviation
The standard deviation of the distribution (sigma)
const Real & _mean
The mean (or expectation) of the distribution (mu)
virtual Real quantile(const Real &p) const override

◆ quantile() [2/3]

Real NormalDistribution::quantile ( const Real &  p,
const Real &  mean,
const Real &  std_dev 
) const
inherited

Definition at line 48 of file NormalDistribution.C.

49 {
50  Real x = (p < 0.5 ? p : 1.0 - p);
51  Real y = std::sqrt(-2.0 * std::log(x));
52  Real sgn = (p - 0.5 < 0.0 ? -1.0 : 1.0);
53  Real Zp = sgn * (y + (_a[0] + _a[1] * y + _a[2] * Utility::pow<2>(y) +
54  _a[3] * Utility::pow<3>(y) + _a[4] * Utility::pow<4>(y)) /
55  (_b[0] + _b[1] * y + _b[2] * Utility::pow<2>(y) +
56  _b[3] * Utility::pow<3>(y) + _b[4] * Utility::pow<4>(y)));
57  return Zp * std_dev + mean;
58 }
const std::vector< Real > _a
const std::vector< Real > _b

◆ quantile() [3/3]

Real TruncatedNormalDistribution::quantile ( const Real &  p,
const Real &  mean,
const Real &  std_dev,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 69 of file TruncatedNormalDistribution.C.

74 {
75  return NormalDistribution::quantile(NormalDistribution::cdf(lower_bound, mean, std_dev) +
76  p * (NormalDistribution::cdf(upper_bound, mean, std_dev) -
77  NormalDistribution::cdf(lower_bound, mean, std_dev)),
78  mean,
79  std_dev);
80 }
virtual Real quantile(const Real &p) const override
virtual Real cdf(const Real &x) const override

Member Data Documentation

◆ _a

const std::vector<Real> NormalDistribution::_a
protectedinherited
Initial value:
= {
-0.322232431088, -1.0, -0.342242088547, -0.0204231210245, -0.0000453642210148}

Coefficients for the rational function used to approximate the quantile

Definition at line 39 of file NormalDistribution.h.

Referenced by NormalDistribution::quantile().

◆ _b

const std::vector<Real> NormalDistribution::_b
protectedinherited
Initial value:
= {
0.099348462606, 0.588581570495, 0.531103462366, 0.10353775285, 0.0038560700634}

Definition at line 42 of file NormalDistribution.h.

Referenced by NormalDistribution::quantile().

◆ _lower_bound

const Real& TruncatedNormalDistribution::_lower_bound
protected

The lower bound for the distribution.

Definition at line 50 of file TruncatedNormalDistribution.h.

Referenced by cdf(), pdf(), quantile(), and TruncatedNormalDistribution().

◆ _mean

const Real& NormalDistribution::_mean
protectedinherited

The mean (or expectation) of the distribution (mu)

Definition at line 47 of file NormalDistribution.h.

Referenced by NormalDistribution::cdf(), cdf(), NormalDistribution::pdf(), pdf(), NormalDistribution::quantile(), and quantile().

◆ _standard_deviation

const Real& NormalDistribution::_standard_deviation
protectedinherited

The standard deviation of the distribution (sigma)

Definition at line 50 of file NormalDistribution.h.

Referenced by NormalDistribution::cdf(), cdf(), NormalDistribution::pdf(), pdf(), NormalDistribution::quantile(), and quantile().

◆ _upper_bound

const Real& TruncatedNormalDistribution::_upper_bound
protected

The upper bound for the distribution.

Definition at line 53 of file TruncatedNormalDistribution.h.

Referenced by cdf(), pdf(), quantile(), and TruncatedNormalDistribution().


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