www.mooseframework.org
LogisticDistribution.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 "LogisticDistribution.h"
11 #include "math.h"
12 #include "libmesh/utility.h"
13 
14 registerMooseObject("StochasticToolsApp", LogisticDistribution);
15 
17 
18 InputParameters
20 {
21  InputParameters params = Distribution::validParams();
22  params.addClassDescription("Logistic distribution.");
23  params.addRequiredParam<Real>("location", "Location or mean of the distribution (alpha or mu)");
24  params.addRequiredParam<Real>("shape", "Shape of the distribution (beta or s)");
25  return params;
26 }
27 
28 LogisticDistribution::LogisticDistribution(const InputParameters & parameters)
29  : Distribution(parameters), _location(getParam<Real>("location")), _shape(getParam<Real>("shape"))
30 {
31 }
32 
33 Real
34 LogisticDistribution::pdf(const Real & x, const Real & location, const Real & shape)
35 {
36  Real z = std::exp(-(x - location) / shape);
37  return z / (shape * Utility::pow<2>(1.0 + z));
38 }
39 
40 Real
41 LogisticDistribution::cdf(const Real & x, const Real & location, const Real & shape)
42 {
43  Real z = std::exp(-(x - location) / shape);
44  return 1.0 / (1.0 + z);
45 }
46 
47 Real
48 LogisticDistribution::quantile(const Real & p, const Real & location, const Real & shape)
49 {
50  return location - shape * std::log(1.0 / p - 1.0);
51 }
52 
53 Real
54 LogisticDistribution::pdf(const Real & x) const
55 {
56  TIME_SECTION(_perf_pdf);
57  return pdf(x, _location, _shape);
58 }
59 
60 Real
61 LogisticDistribution::cdf(const Real & x) const
62 {
63  TIME_SECTION(_perf_cdf);
64  return cdf(x, _location, _shape);
65 }
66 
67 Real
68 LogisticDistribution::quantile(const Real & p) const
69 {
70  TIME_SECTION(_perf_quantile);
71  return quantile(p, _location, _shape);
72 }
defineLegacyParams
defineLegacyParams(LogisticDistribution)
LogisticDistribution::_shape
const Real & _shape
The shape of the distribution (beta or s)
Definition: LogisticDistribution.h:42
LogisticDistribution::validParams
static InputParameters validParams()
Definition: LogisticDistribution.C:19
LogisticDistribution::pdf
virtual Real pdf(const Real &x) const override
Definition: LogisticDistribution.C:54
registerMooseObject
registerMooseObject("StochasticToolsApp", LogisticDistribution)
LogisticDistribution::quantile
virtual Real quantile(const Real &p) const override
Definition: LogisticDistribution.C:68
LogisticDistribution
A class used to generate a logistic distribution.
Definition: LogisticDistribution.h:22
LogisticDistribution::cdf
virtual Real cdf(const Real &x) const override
Definition: LogisticDistribution.C:61
validParams
InputParameters validParams()
LogisticDistribution::_location
const Real & _location
The location or mean of the distribution (alpha or mu)
Definition: LogisticDistribution.h:39
LogisticDistribution.h
LogisticDistribution::LogisticDistribution
LogisticDistribution(const InputParameters &parameters)
Definition: LogisticDistribution.C:28