LCOV - code coverage report
Current view: top level - src/distributions - Logistic.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #31405 (292dce) with base fef103 Lines: 23 24 95.8 %
Date: 2025-09-04 07:57:52 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14