www.mooseframework.org
JohnsonSBDistribution.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "JohnsonSBDistribution.h"
11 #include "math.h"
12 #include "libmesh/utility.h"
13 
14 registerMooseObject("StochasticToolsApp", JohnsonSBDistribution);
15 
17 
18 InputParameters
20 {
21  InputParameters params = NormalDistribution::validParams();
22  params.addClassDescription("Johnson Special Bounded (SB) distribution.");
23 
24  params.set<Real>("mean") = 0.0;
25  params.set<Real>("standard_deviation") = 1.0;
26  params.suppressParameter<Real>("mean");
27  params.suppressParameter<Real>("standard_deviation");
28 
29  params.addRequiredParam<Real>("a", "Lower location parameter");
30  params.addRequiredParam<Real>("b", "Upper location parameter");
31  params.addRequiredParam<Real>("alpha_1", "Shape parameter (sometimes called a)");
32  params.addRequiredParam<Real>("alpha_2", "Shape parameter (sometimes called b)");
33 
34  return params;
35 }
36 
37 JohnsonSBDistribution::JohnsonSBDistribution(const InputParameters & parameters)
38  : NormalDistribution(parameters),
39  _lower(getParam<Real>("a")),
40  _upper(getParam<Real>("b")),
41  _alpha_1(getParam<Real>("alpha_1")),
42  _alpha_2(getParam<Real>("alpha_2"))
43 {
44 }
45 
46 Real
48  const Real & x, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
49 {
50  if (x <= a)
51  return 0.0;
52  else if (x < b)
53  {
54  return (alpha_2 * (b - a)) / ((x - a) * (b - x) * std::sqrt(2.0 * M_PI)) *
55  std::exp(-0.5 * Utility::pow<2>(alpha_1 + alpha_2 * std::log((x - a) / (b - x))));
56  }
57  else
58  return 0.0;
59 }
60 
61 Real
63  const Real & x, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
64 {
65  if (x <= a)
66  return 0.0;
67  else if (x < b)
68  {
69  return NormalDistribution::cdf(alpha_1 + alpha_2 * std::log((x - a) / (b - x)), 0.0, 1.0);
70  }
71  else
72  return 0.0;
73 }
74 
75 Real
77  const Real & p, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
78 {
79  const Real Z = NormalDistribution::quantile(p, 0.0, 1.0);
80  return (a + b * std::exp((Z - alpha_1) / alpha_2)) / (1.0 + std::exp((Z - alpha_1) / alpha_2));
81 }
82 
83 Real
84 JohnsonSBDistribution::pdf(const Real & x) const
85 {
86  TIME_SECTION(_perf_pdf);
87  return pdf(x, _lower, _upper, _alpha_1, _alpha_2);
88 }
89 
90 Real
91 JohnsonSBDistribution::cdf(const Real & x) const
92 {
93  TIME_SECTION(_perf_cdf);
94  return cdf(x, _lower, _upper, _alpha_1, _alpha_2);
95 }
96 
97 Real
98 JohnsonSBDistribution::quantile(const Real & p) const
99 {
100  TIME_SECTION(_perf_quantile);
101  return quantile(p, _lower, _upper, _alpha_1, _alpha_2);
102 }
JohnsonSBDistribution::_lower
const Real & _lower
The lower location parameter, a.
Definition: JohnsonSBDistribution.h:42
NormalDistribution::cdf
virtual Real cdf(const Real &x) const override
Definition: NormalDistribution.C:76
JohnsonSBDistribution::_alpha_1
const Real & _alpha_1
The first shape parameter, alpha_1.
Definition: JohnsonSBDistribution.h:48
defineLegacyParams
defineLegacyParams(JohnsonSBDistribution)
JohnsonSBDistribution::_upper
const Real & _upper
The upper location parameter, b.
Definition: JohnsonSBDistribution.h:45
JohnsonSBDistribution::JohnsonSBDistribution
JohnsonSBDistribution(const InputParameters &parameters)
Definition: JohnsonSBDistribution.C:37
NormalDistribution::validParams
static InputParameters validParams()
Definition: NormalDistribution.C:25
JohnsonSBDistribution.h
JohnsonSBDistribution::validParams
static InputParameters validParams()
Definition: JohnsonSBDistribution.C:19
registerMooseObject
registerMooseObject("StochasticToolsApp", JohnsonSBDistribution)
JohnsonSBDistribution::_alpha_2
const Real & _alpha_2
The second shape parameter, alpha_2.
Definition: JohnsonSBDistribution.h:51
JohnsonSBDistribution
A class used to generate a Johnson SB distribution.
Definition: JohnsonSBDistribution.h:22
NormalDistribution::quantile
virtual Real quantile(const Real &p) const override
Definition: NormalDistribution.C:83
JohnsonSBDistribution::cdf
virtual Real cdf(const Real &x) const override
Definition: JohnsonSBDistribution.C:91
NormalDistribution
A class used to generate a normal distribution.
Definition: NormalDistribution.h:22
JohnsonSBDistribution::quantile
virtual Real quantile(const Real &p) const override
Definition: JohnsonSBDistribution.C:98
JohnsonSBDistribution::pdf
virtual Real pdf(const Real &x) const override
Definition: JohnsonSBDistribution.C:84