https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Weibull.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 "Weibull.h"
11#include "math.h"
12#include "libmesh/utility.h"
13
14registerMooseObject("StochasticToolsApp", Weibull);
15
18{
20 params.addClassDescription("Three-parameter Weibull distribution.");
21 params.addRequiredParam<Real>("location", "Location parameter (a or low)");
22 params.addRequiredRangeCheckedParam<Real>("scale", "scale > 0", "Scale parameter (b or lambda)");
23 params.addRequiredRangeCheckedParam<Real>("shape", "shape > 0", "Shape parameter (c or k)");
24 return params;
25}
26
28 : Distribution(parameters),
29 _a(getParam<Real>("location")),
30 _b(getParam<Real>("scale")),
31 _c(getParam<Real>("shape"))
32{
33}
34
35Real
36Weibull::pdf(const Real & x, const Real & location, const Real & scale, const Real & shape)
37{
38 if (x <= location)
39 return 0.0;
40 else
41 {
42 const Real y = (x - location) / scale;
43 return shape / scale * std::pow(y, shape - 1.0) * std::exp(-std::pow(y, shape));
44 }
45}
46
47Real
48Weibull::cdf(const Real & x, const Real & location, const Real & scale, const Real & shape)
49{
50 if (x <= location)
51 return 0.0;
52 else
53 {
54 const Real y = (x - location) / scale;
55 return 1.0 - std::exp(-std::pow(y, shape));
56 }
57}
58
59Real
60Weibull::quantile(const Real & p, const Real & location, const Real & scale, const Real & shape)
61{
62 return location + scale * std::pow(-std::log(1 - p), 1.0 / shape);
63}
64
65Real
66Weibull::pdf(const Real & x) const
67{
68 return pdf(x, _a, _b, _c);
69}
70
71Real
72Weibull::cdf(const Real & x) const
73{
74 return cdf(x, _a, _b, _c);
75}
76
77Real
78Weibull::quantile(const Real & p) const
79{
80 return quantile(p, _a, _b, _c);
81}
const std::vector< double > y
const std::vector< double > x
const Real p
Real scale
registerMooseObject("StochasticToolsApp", Weibull)
static InputParameters validParams()
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
A class used to generate a three-parameter Weibull distribution.
Definition Weibull.h:18
const Real & _a
The location parameter (a or low)
Definition Weibull.h:35
Weibull(const InputParameters &parameters)
Definition Weibull.C:27
virtual Real pdf(const Real &x) const override
Definition Weibull.C:66
const Real & _c
The shape parameter (c or k)
Definition Weibull.h:41
virtual Real cdf(const Real &x) const override
Definition Weibull.C:72
static InputParameters validParams()
Definition Weibull.C:17
const Real & _b
The scale parameter (b or lambda)
Definition Weibull.h:38
virtual Real quantile(const Real &p) const override
Definition Weibull.C:78