https://mooseframework.inl.gov
JohnsonSB.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 "JohnsonSB.h"
11 #include "math.h"
12 #include "libmesh/utility.h"
13 
14 registerMooseObject("StochasticToolsApp", JohnsonSB);
15 
18 {
20  params.addClassDescription("Johnson Special Bounded (SB) distribution.");
21 
22  params.set<Real>("mean") = 0.0;
23  params.set<Real>("standard_deviation") = 1.0;
24  params.suppressParameter<Real>("mean");
25  params.suppressParameter<Real>("standard_deviation");
26 
27  params.addRequiredParam<Real>("a", "Lower location parameter");
28  params.addRequiredParam<Real>("b", "Upper location parameter");
29  params.addRequiredParam<Real>("alpha_1", "Shape parameter (sometimes called a)");
30  params.addRequiredParam<Real>("alpha_2", "Shape parameter (sometimes called b)");
31 
32  return params;
33 }
34 
36  : Normal(parameters),
37  _lower(getParam<Real>("a")),
38  _upper(getParam<Real>("b")),
39  _alpha_1(getParam<Real>("alpha_1")),
40  _alpha_2(getParam<Real>("alpha_2"))
41 {
42 }
43 
44 Real
46  const Real & x, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
47 {
48  if (x <= a)
49  return 0.0;
50  else if (x < b)
51  {
52  return (alpha_2 * (b - a)) / ((x - a) * (b - x) * std::sqrt(2.0 * M_PI)) *
53  std::exp(-0.5 * Utility::pow<2>(alpha_1 + alpha_2 * std::log((x - a) / (b - x))));
54  }
55  else
56  return 0.0;
57 }
58 
59 Real
61  const Real & x, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
62 {
63  if (x <= a)
64  return 0.0;
65  else if (x < b)
66  {
67  return Normal::cdf(alpha_1 + alpha_2 * std::log((x - a) / (b - x)), 0.0, 1.0);
68  }
69  else
70  return 0.0;
71 }
72 
73 Real
75  const Real & p, const Real & a, const Real & b, const Real & alpha_1, const Real & alpha_2)
76 {
77  const Real Z = Normal::quantile(p, 0.0, 1.0);
78  return (a + b * std::exp((Z - alpha_1) / alpha_2)) / (1.0 + std::exp((Z - alpha_1) / alpha_2));
79 }
80 
81 Real
82 JohnsonSB::pdf(const Real & x) const
83 {
84  return pdf(x, _lower, _upper, _alpha_1, _alpha_2);
85 }
86 
87 Real
88 JohnsonSB::cdf(const Real & x) const
89 {
90  return cdf(x, _lower, _upper, _alpha_1, _alpha_2);
91 }
92 
93 Real
94 JohnsonSB::quantile(const Real & p) const
95 {
96  return quantile(p, _lower, _upper, _alpha_1, _alpha_2);
97 }
registerMooseObject("StochasticToolsApp", JohnsonSB)
A class used to generate a Johnson SB distribution.
Definition: JohnsonSB.h:17
virtual Real cdf(const Real &x) const override
Definition: Normal.C:74
A class used to generate a normal distribution.
Definition: Normal.h:17
T & set(const std::string &name, bool quiet_mode=false)
static InputParameters validParams()
Definition: Normal.C:23
void addRequiredParam(const std::string &name, const std::string &doc_string)
void suppressParameter(const std::string &name)
JohnsonSB(const InputParameters &parameters)
Definition: JohnsonSB.C:35
const std::vector< double > x
const Real & _alpha_2
The second shape parameter, alpha_2.
Definition: JohnsonSB.h:46
virtual Real pdf(const Real &x) const override
Definition: JohnsonSB.C:82
static InputParameters validParams()
Definition: JohnsonSB.C:17
static const std::string Z
Definition: NS.h:169
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real & _alpha_1
The first shape parameter, alpha_1.
Definition: JohnsonSB.h:43
void addClassDescription(const std::string &doc_string)
const Real & _lower
The lower location parameter, a.
Definition: JohnsonSB.h:37
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80
virtual Real quantile(const Real &p) const override
Definition: JohnsonSB.C:94
virtual Real cdf(const Real &x) const override
Definition: JohnsonSB.C:88
const Real & _upper
The upper location parameter, b.
Definition: JohnsonSB.h:40