https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Uniform.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "Uniform.h"
11
12registerMooseObject("StochasticToolsApp", Uniform);
13
16{
18 params.addClassDescription("Continuous uniform distribution.");
19 params.addParam<Real>("lower_bound", 0.0, "Distribution lower bound");
20 params.addParam<Real>("upper_bound", 1.0, "Distribution upper bound");
21 return params;
22}
23
25 : Distribution(parameters),
26 _lower_bound(getParam<Real>("lower_bound")),
27 _upper_bound(getParam<Real>("upper_bound"))
28{
30 mooseError("The lower bound is larger than the upper bound!");
31}
32
33Real
34Uniform::pdf(const Real & x, const Real & lower_bound, const Real & upper_bound)
35{
36 if (x < lower_bound || x > upper_bound)
37 return 0.0;
38 else
39 return 1.0 / (upper_bound - lower_bound);
40}
41
42Real
43Uniform::cdf(const Real & x, const Real & lower_bound, const Real & upper_bound)
44{
45 if (x < lower_bound)
46 return 0.0;
47 else if (x > upper_bound)
48 return 1.0;
49 else
50 return (x - lower_bound) / (upper_bound - lower_bound);
51}
52
53Real
54Uniform::quantile(const Real & y, const Real & lower_bound, const Real & upper_bound)
55{
56 if (y < 0 || y > 1)
57 ::mooseError("The cdf_value provided is out of range 0 to 1.");
58 else
59 return y * (upper_bound - lower_bound) + lower_bound;
60}
61
62Real
63Uniform::pdf(const Real & x) const
64{
66}
67
68Real
69Uniform::cdf(const Real & x) const
70{
72}
73
74Real
75Uniform::quantile(const Real & y) const
76{
78}
const std::vector< double > y
const std::vector< double > x
registerMooseObject("StochasticToolsApp", Uniform)
static InputParameters validParams()
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)
void mooseError(Args &&... args) const
A class used to generate uniform distribution.
Definition Uniform.h:18
static InputParameters validParams()
Definition Uniform.C:15
static Real quantile(const Real &y, const Real &lower_bound, const Real &upper_bound)
Definition Uniform.C:54
const Real & _lower_bound
The lower bound for the uniform distribution.
Definition Uniform.h:34
Uniform(const InputParameters &parameters)
Definition Uniform.C:24
const Real & _upper_bound
The upper bound for the uniform distribution.
Definition Uniform.h:37
static Real pdf(const Real &x, const Real &lower_bound, const Real &upper_bound)
Definition Uniform.C:34
static Real cdf(const Real &x, const Real &lower_bound, const Real &upper_bound)
Definition Uniform.C:43