https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
14registerMooseObject("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
44Real
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
59Real
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
73Real
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
81Real
82JohnsonSB::pdf(const Real & x) const
83{
84 return pdf(x, _lower, _upper, _alpha_1, _alpha_2);
85}
86
87Real
88JohnsonSB::cdf(const Real & x) const
89{
90 return cdf(x, _lower, _upper, _alpha_1, _alpha_2);
91}
92
93Real
94JohnsonSB::quantile(const Real & p) const
95{
97}
const std::vector< double > x
const Real p
registerMooseObject("StochasticToolsApp", JohnsonSB)
void suppressParameter(const std::string &name)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
A class used to generate a Johnson SB distribution.
Definition JohnsonSB.h:18
virtual Real pdf(const Real &x) const override
Definition JohnsonSB.C:82
const Real & _upper
The upper location parameter, b.
Definition JohnsonSB.h:40
const Real & _alpha_2
The second shape parameter, alpha_2.
Definition JohnsonSB.h:46
static InputParameters validParams()
Definition JohnsonSB.C:17
const Real & _lower
The lower location parameter, a.
Definition JohnsonSB.h:37
virtual Real quantile(const Real &p) const override
Definition JohnsonSB.C:94
JohnsonSB(const InputParameters &parameters)
Definition JohnsonSB.C:35
const Real & _alpha_1
The first shape parameter, alpha_1.
Definition JohnsonSB.h:43
virtual Real cdf(const Real &x) const override
Definition JohnsonSB.C:88
A class used to generate a normal distribution.
Definition Normal.h:18
static InputParameters validParams()
Definition Normal.C:23
virtual Real cdf(const Real &x) const override
Definition Normal.C:74
virtual Real quantile(const Real &p) const override
Definition Normal.C:80