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

A class used to generate uniform distribution. More...

#include <UniformDistribution.h>

Inheritance diagram for UniformDistribution:
[legend]

Public Member Functions

 UniformDistribution (const InputParameters &parameters)
 
Real pdf (const Real &x, const Real &lower_bound, const Real &upper_bound) const
 
Real cdf (const Real &x, const Real &lower_bound, const Real &upper_bound) const
 
Real quantile (const Real &y, const Real &lower_bound, const Real &upper_bound) const
 
virtual Real pdf (const Real &x) const override
 
virtual Real cdf (const Real &x) const override
 
virtual Real quantile (const Real &y) const override
 

Protected Attributes

const Real & _lower_bound
 The lower bound for the uniform distribution. More...
 
const Real & _upper_bound
 The upper bound for the uniform distribution. More...
 

Detailed Description

A class used to generate uniform distribution.

Definition at line 22 of file UniformDistribution.h.

Constructor & Destructor Documentation

◆ UniformDistribution()

UniformDistribution::UniformDistribution ( const InputParameters &  parameters)

Definition at line 25 of file UniformDistribution.C.

26  : Distribution(parameters),
27  _lower_bound(getParam<Real>("lower_bound")),
28  _upper_bound(getParam<Real>("upper_bound"))
29 {
31  mooseError("The lower bound is larger than the upper bound!");
32 }
const Real & _upper_bound
The upper bound for the uniform distribution.
const Real & _lower_bound
The lower bound for the uniform distribution.

Member Function Documentation

◆ cdf() [1/2]

Real UniformDistribution::cdf ( const Real &  x,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 44 of file UniformDistribution.C.

Referenced by cdf().

45 {
46  if (x < lower_bound)
47  return 0.0;
48  else if (x > upper_bound)
49  return 1.0;
50  else
51  return (x - lower_bound) / (upper_bound - lower_bound);
52 }

◆ cdf() [2/2]

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

Definition at line 72 of file UniformDistribution.C.

73 {
74  return cdf(x, _lower_bound, _upper_bound);
75 }
const Real & _upper_bound
The upper bound for the uniform distribution.
const Real & _lower_bound
The lower bound for the uniform distribution.
Real cdf(const Real &x, const Real &lower_bound, const Real &upper_bound) const

◆ pdf() [1/2]

Real UniformDistribution::pdf ( const Real &  x,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 35 of file UniformDistribution.C.

Referenced by pdf().

36 {
37  if (x < lower_bound || x > upper_bound)
38  return 0.0;
39  else
40  return 1.0 / (upper_bound - lower_bound);
41 }

◆ pdf() [2/2]

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

Definition at line 66 of file UniformDistribution.C.

67 {
68  return pdf(x, _lower_bound, _upper_bound);
69 }
const Real & _upper_bound
The upper bound for the uniform distribution.
const Real & _lower_bound
The lower bound for the uniform distribution.
Real pdf(const Real &x, const Real &lower_bound, const Real &upper_bound) const

◆ quantile() [1/2]

Real UniformDistribution::quantile ( const Real &  y,
const Real &  lower_bound,
const Real &  upper_bound 
) const

Definition at line 55 of file UniformDistribution.C.

Referenced by quantile().

58 {
59  if (y < 0 || y > 1)
60  mooseError("The cdf_value provided is out of range 0 to 1.");
61  else
62  return y * (upper_bound - lower_bound) + lower_bound;
63 }

◆ quantile() [2/2]

Real UniformDistribution::quantile ( const Real &  y) const
overridevirtual

Definition at line 78 of file UniformDistribution.C.

79 {
81 }
const Real & _upper_bound
The upper bound for the uniform distribution.
const Real & _lower_bound
The lower bound for the uniform distribution.
Real quantile(const Real &y, const Real &lower_bound, const Real &upper_bound) const

Member Data Documentation

◆ _lower_bound

const Real& UniformDistribution::_lower_bound
protected

The lower bound for the uniform distribution.

Definition at line 37 of file UniformDistribution.h.

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

◆ _upper_bound

const Real& UniformDistribution::_upper_bound
protected

The upper bound for the uniform distribution.

Definition at line 40 of file UniformDistribution.h.

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


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