https://mooseframework.inl.gov
Lognormal.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 "Lognormal.h"
11 #include "Normal.h"
12 #include "math.h"
13 #include "libmesh/utility.h"
14 
15 registerMooseObject("StochasticToolsApp", Lognormal);
16 
19 {
21  params.addClassDescription("Lognormal distribution");
22  params.addRequiredParam<Real>("location", "The Lognormal location parameter (m or mu).");
23  params.addRequiredParam<Real>("scale", "The Lognormal scale parameter (s or sigma).");
24  return params;
25 }
26 
28  : Distribution(parameters), _location(getParam<Real>("location")), _scale(getParam<Real>("scale"))
29 {
30 }
31 
32 Real
33 Lognormal::pdf(const Real & x, const Real & location, const Real & scale)
34 {
35  return 1.0 / (x * scale * std::sqrt(2.0 * M_PI)) *
36  std::exp(-0.5 * Utility::pow<2>((std::log(x) - location) / scale));
37 }
38 
39 Real
40 Lognormal::cdf(const Real & x, const Real & location, const Real & scale)
41 {
42  return 0.5 * (1.0 + std::erf((std::log(x) - location) / (scale * std::sqrt(2.0))));
43 }
44 
45 Real
46 Lognormal::quantile(const Real & p, const Real & location, const Real & scale)
47 {
48  return std::exp(Normal::quantile(p, location, scale));
49 }
50 
51 Real
52 Lognormal::pdf(const Real & x) const
53 {
54  return pdf(x, _location, _scale);
55 }
56 
57 Real
58 Lognormal::cdf(const Real & x) const
59 {
60  return cdf(x, _location, _scale);
61 }
62 
63 Real
64 Lognormal::quantile(const Real & p) const
65 {
66  return quantile(p, _location, _scale);
67 }
void scale(MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.)
virtual Real pdf(const Real &x) const override
Definition: Lognormal.C:52
void addRequiredParam(const std::string &name, const std::string &doc_string)
const Real & _location
The lognormal location parameter (m or mu)
Definition: Lognormal.h:34
virtual Real cdf(const Real &x) const override
Definition: Lognormal.C:58
static InputParameters validParams()
Definition: Lognormal.C:18
const std::vector< double > x
const Real & _scale
The lognormal scale parameter (s or sigma)
Definition: Lognormal.h:37
registerMooseObject("StochasticToolsApp", Lognormal)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
Lognormal(const InputParameters &parameters)
Definition: Lognormal.C:27
virtual Real quantile(const Real &p) const override
Definition: Lognormal.C:64
A class used to generate a lognormal distribution.
Definition: Lognormal.h:17
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80