https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
TruncatedNormal Class Reference

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

#include <TruncatedNormal.h>

Inheritance diagram for TruncatedNormal:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 TruncatedNormal (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
 
virtual Real median () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
PerfGraphperfGraph ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static Real pdf (const Real &x, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound)
 
static Real cdf (const Real &x, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound)
 
static Real quantile (const Real &p, const Real &mean, const Real &std_dev, const Real &lower_bound, const Real &upper_bound)
 
static Real pdf (const Real &x, const Real &mean, const Real &std_dev)
 
static Real cdf (const Real &x, const Real &mean, const Real &std_dev)
 
static Real quantile (const Real &p, const Real &mean, const Real &std_dev)
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

const Real & _lower_bound
 The lower bound for the distribution.
 
const Real & _upper_bound
 The upper bound for the distribution.
 
const Real & _mean
 The mean (or expectation) of the distribution (mu)
 
const Real & _standard_deviation
 The standard deviation of the distribution (sigma)
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static const std::array< Real, 6 > _a
 
static const std::array< Real, 6 > _b
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 

Detailed Description

A class used to generate a truncated normal distribution.

Definition at line 17 of file TruncatedNormal.h.

Constructor & Destructor Documentation

◆ TruncatedNormal()

TruncatedNormal::TruncatedNormal ( const InputParameters parameters)

Definition at line 26 of file TruncatedNormal.C.

28 _lower_bound(getParam<Real>("lower_bound")),
29 _upper_bound(getParam<Real>("upper_bound"))
30{
32 mooseError("lower_bound in truncated normal distribution must be less than upper_bound.");
33}
const InputParameters & parameters() const
void mooseError(Args &&... args) const
A class used to generate a normal distribution.
Definition Normal.h:18
const Real & _lower_bound
The lower bound for the distribution.
const Real & _upper_bound
The upper bound for the distribution.

Member Function Documentation

◆ cdf() [1/3]

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

Reimplemented from Normal.

Definition at line 85 of file TruncatedNormal.C.

86{
88}
const std::vector< double > x
const Real & _standard_deviation
The standard deviation of the distribution (sigma)
Definition Normal.h:43
const Real & _mean
The mean (or expectation) of the distribution (mu)
Definition Normal.h:40
virtual Real cdf(const Real &x) const override

Referenced by cdf().

◆ cdf() [2/3]

Real Normal::cdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev 
)
staticinherited

Definition at line 48 of file Normal.C.

49{
50 return 0.5 * (1.0 + std::erf((x - mean) / (std_dev * std::sqrt(2.0))));
51}

◆ cdf() [3/3]

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

Definition at line 50 of file TruncatedNormal.C.

55{
56
57 if (x <= lower_bound || x >= upper_bound)
58 return 0.0;
59 else
60 return (Normal::cdf(x, mean, std_dev) - Normal::cdf(lower_bound, mean, std_dev)) /
61 (Normal::cdf(upper_bound, mean, std_dev) - Normal::cdf(lower_bound, mean, std_dev));
62}
virtual Real cdf(const Real &x) const override
Definition Normal.C:74

◆ pdf() [1/3]

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

Reimplemented from Normal.

Definition at line 79 of file TruncatedNormal.C.

80{
82}
virtual Real pdf(const Real &x) const override

Referenced by TruncatedGaussian::function(), and pdf().

◆ pdf() [2/3]

Real Normal::pdf ( const Real &  x,
const Real &  mean,
const Real &  std_dev 
)
staticinherited

Definition at line 41 of file Normal.C.

42{
43 return 1.0 / (std_dev * std::sqrt(2.0 * M_PI)) *
44 std::exp(-0.5 * Utility::pow<2>((x - mean) / std_dev));
45}

◆ pdf() [3/3]

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

Definition at line 36 of file TruncatedNormal.C.

41{
42 if (x <= lower_bound || x >= upper_bound)
43 return 0.0;
44 else
45 return (Normal::pdf(x, mean, std_dev)) /
46 (Normal::cdf(upper_bound, mean, std_dev) - Normal::cdf(lower_bound, mean, std_dev));
47}
virtual Real pdf(const Real &x) const override
Definition Normal.C:68

◆ quantile() [1/3]

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

Reimplemented from Normal.

Definition at line 91 of file TruncatedNormal.C.

92{
94}
const Real p
virtual Real quantile(const Real &p) const override

Referenced by IndependentGaussianMH::proposeSamples(), and quantile().

◆ quantile() [2/3]

Real Normal::quantile ( const Real &  p,
const Real &  mean,
const Real &  std_dev 
)
staticinherited

Definition at line 54 of file Normal.C.

55{
56 const Real x = (p < 0.5 ? p : 1.0 - p);
57 const Real y = std::sqrt(-2.0 * std::log(x));
58 const Real y2 = y * y;
59 const Real y3 = y2 * y;
60 const Real y4 = y3 * y;
61 const Real sgn = (p - 0.5 < 0.0 ? -1.0 : 1.0);
62 const Real Zp = sgn * (y + (_a[0] + _a[1] * y + _a[2] * y2 + _a[3] * y3 + _a[4] * y4) /
63 (_b[0] + _b[1] * y + _b[2] * y2 + _b[3] * y3 + _b[4] * y4));
64 return Zp * std_dev + mean;
65}
const std::vector< double > y
static const std::array< Real, 6 > _a
Definition Normal.h:16
static const std::array< Real, 6 > _b
Definition Normal.h:19
int sgn(T val)
The sign function.
Definition Numerics.h:41
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ quantile() [3/3]

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

Definition at line 65 of file TruncatedNormal.C.

70{
71 return Normal::quantile(
72 Normal::cdf(lower_bound, mean, std_dev) +
73 p * (Normal::cdf(upper_bound, mean, std_dev) - Normal::cdf(lower_bound, mean, std_dev)),
74 mean,
75 std_dev);
76}
virtual Real quantile(const Real &p) const override
Definition Normal.C:80

◆ validParams()

InputParameters TruncatedNormal::validParams ( )
static

Definition at line 15 of file TruncatedNormal.C.

16{
18 params.addClassDescription("Truncated normal distribution");
19 params.addParam<Real>(
20 "lower_bound", -std::numeric_limits<Real>::max(), "Lower bound of the distribution ");
21 params.addParam<Real>(
22 "upper_bound", std::numeric_limits<Real>::max(), "Upper bound of the distribution ");
23 return params;
24}
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Definition Normal.C:23

Referenced by TruncatedNormalDistribution::validParams().

Member Data Documentation

◆ _a

const std::array< Real, 6 > Normal::_a
staticprotectedinherited
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 16 of file Normal.h.

Referenced by Normal::quantile().

◆ _b

const std::array< Real, 6 > Normal::_b
staticprotectedinherited
Initial value:
= {
{0.099348462606, 0.588581570495, 0.531103462366, 0.10353775285, 0.0038560700634}}

Definition at line 19 of file Normal.h.

19 :

Referenced by Normal::quantile().

◆ _lower_bound

const Real& TruncatedNormal::_lower_bound
protected

The lower bound for the distribution.

Definition at line 46 of file TruncatedNormal.h.

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

◆ _mean

const Real& Normal::_mean
protectedinherited

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

Definition at line 40 of file Normal.h.

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

◆ _standard_deviation

const Real& Normal::_standard_deviation
protectedinherited

The standard deviation of the distribution (sigma)

Definition at line 43 of file Normal.h.

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

◆ _upper_bound

const Real& TruncatedNormal::_upper_bound
protected

The upper bound for the distribution.

Definition at line 49 of file TruncatedNormal.h.

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


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