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