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 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<NormalDistribution>();
21  params.addClassDescription("Johnson Special Bounded (SB) distribution.");
22 
23  params.set<Real>("mean") = 0.0;
24  params.set<Real>("standard_deviation") = 1.0;
25  params.suppressParameter<Real>("mean");
26  params.suppressParameter<Real>("standard_deviation");
27 
28  params.addRequiredParam<Real>("a", "Lower location parameter");
29  params.addRequiredParam<Real>("b", "Upper location parameter");
30  params.addRequiredParam<Real>("alpha_1", "Shape parameter (sometimes called a)");
31  params.addRequiredParam<Real>("alpha_2", "Shape parameter (sometimes called b)");
32 
33  return params;
34 }
35 
36 JohnsonSBDistribution::JohnsonSBDistribution(const InputParameters & parameters)
37  : NormalDistribution(parameters),
38  _lower(getParam<Real>("a")),
39  _upper(getParam<Real>("b")),
40  _alpha_1(getParam<Real>("alpha_1")),
41  _alpha_2(getParam<Real>("alpha_2"))
42 {
43 }
44 
45 Real
47  const Real & a,
48  const Real & b,
49  const Real & alpha_1,
50  const Real & alpha_2) const
51 {
52  if (x <= a)
53  return 0.0;
54  else if (x < b)
55  {
56  return (alpha_2 * (b - a)) / ((x - a) * (b - x) * std::sqrt(2.0 * M_PI)) *
57  std::exp(-0.5 * Utility::pow<2>(alpha_1 + alpha_2 * std::log((x - a) / (b - x))));
58  }
59  else
60  return 0.0;
61 }
62 
63 Real
65  const Real & a,
66  const Real & b,
67  const Real & alpha_1,
68  const Real & alpha_2) const
69 {
70  if (x <= a)
71  return 0.0;
72  else if (x < b)
73  {
74  return NormalDistribution::cdf(alpha_1 + alpha_2 * std::log((x - a) / (b - x)));
75  }
76  else
77  return 0.0;
78 }
79 
80 Real
82  const Real & a,
83  const Real & b,
84  const Real & alpha_1,
85  const Real & alpha_2) const
86 {
87  const Real Z = NormalDistribution::quantile(p);
88  return (a + b * std::exp((Z - alpha_1) / alpha_2)) / (1.0 + std::exp((Z - alpha_1) / alpha_2));
89 }
90 
91 Real
92 JohnsonSBDistribution::pdf(const Real & x) const
93 {
94  return pdf(x, _lower, _upper, _alpha_1, _alpha_2);
95 }
96 
97 Real
98 JohnsonSBDistribution::cdf(const Real & x) const
99 {
100  return cdf(x, _lower, _upper, _alpha_1, _alpha_2);
101 }
102 
103 Real
104 JohnsonSBDistribution::quantile(const Real & p) const
105 {
106  return quantile(p, _lower, _upper, _alpha_1, _alpha_2);
107 }
virtual Real pdf(const Real &x) const override
const Real & _alpha_1
The first shape parameter, alpha_1.
virtual Real quantile(const Real &p) const override
const Real & _upper
The upper location parameter, b.
InputParameters validParams< NormalDistribution >()
virtual Real quantile(const Real &p) const override
const Real & _alpha_2
The second shape parameter, alpha_2.
virtual Real cdf(const Real &x) const override
A class used to generate a normal distribution.
A class used to generate a Johnson SB distribution.
virtual Real cdf(const Real &x) const override
const Real & _lower
The lower location parameter, a.
JohnsonSBDistribution(const InputParameters &parameters)
InputParameters validParams< JohnsonSBDistribution >()
registerMooseObject("StochasticToolsApp", JohnsonSBDistribution)