Line data Source code
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 "Logistic.h" 11 : #include "math.h" 12 : #include "libmesh/utility.h" 13 : 14 : registerMooseObject("StochasticToolsApp", Logistic); 15 : 16 : InputParameters 17 32 : Logistic::validParams() 18 : { 19 32 : InputParameters params = Distribution::validParams(); 20 32 : params.addClassDescription("Logistic distribution."); 21 64 : params.addRequiredParam<Real>("location", "Location or mean of the distribution (alpha or mu)"); 22 64 : params.addRequiredParam<Real>("shape", "Shape of the distribution (beta or s)"); 23 32 : return params; 24 0 : } 25 : 26 16 : Logistic::Logistic(const InputParameters & parameters) 27 48 : : Distribution(parameters), _location(getParam<Real>("location")), _shape(getParam<Real>("shape")) 28 : { 29 16 : } 30 : 31 : Real 32 16 : Logistic::pdf(const Real & x, const Real & location, const Real & shape) 33 : { 34 16 : Real z = std::exp(-(x - location) / shape); 35 16 : return z / (shape * Utility::pow<2>(1.0 + z)); 36 : } 37 : 38 : Real 39 16 : Logistic::cdf(const Real & x, const Real & location, const Real & shape) 40 : { 41 16 : Real z = std::exp(-(x - location) / shape); 42 16 : return 1.0 / (1.0 + z); 43 : } 44 : 45 : Real 46 16 : Logistic::quantile(const Real & p, const Real & location, const Real & shape) 47 : { 48 16 : return location - shape * std::log(1.0 / p - 1.0); 49 : } 50 : 51 : Real 52 16 : Logistic::pdf(const Real & x) const 53 : { 54 16 : return pdf(x, _location, _shape); 55 : } 56 : 57 : Real 58 16 : Logistic::cdf(const Real & x) const 59 : { 60 16 : return cdf(x, _location, _shape); 61 : } 62 : 63 : Real 64 16 : Logistic::quantile(const Real & p) const 65 : { 66 16 : return quantile(p, _location, _shape); 67 : }