ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
distribution
ROL_Gumbel.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Rapid Optimization Library (ROL) Package
4
//
5
// Copyright 2014 NTESS and the ROL contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef ROL_GUMBEL_HPP
11
#define ROL_GUMBEL_HPP
12
13
#include "
ROL_Distribution.hpp
"
14
#include "ROL_ParameterList.hpp"
15
16
namespace
ROL
{
17
18
template
<
class
Real>
19
class
Gumbel
:
public
Distribution
<Real> {
20
private
:
21
Real
loc_
;
22
Real
scale_
;
23
24
void
checkInputs
(
const
Real loc,
const
Real scale)
const
{
25
if
(scale <=
static_cast<
Real
>
(0)) {
26
throw
Exception::NotImplemented
(
">>> (Gumbel::Gumbel): Scale must be greater than zero!"
);
27
}
28
}
29
30
public
:
31
Gumbel
(
const
Real loc = 0.,
const
Real scale = 1.)
32
:
loc_
(loc),
scale_
(scale) {
33
checkInputs
(
loc_
,
scale_
);
34
}
35
36
Gumbel
(ROL::ParameterList &parlist) {
37
loc_
= parlist.sublist(
"SOL"
).sublist(
"Distribution"
).sublist(
"Gumbel"
).get(
"Location"
,0.);
38
scale_
= parlist.sublist(
"SOL"
).sublist(
"Distribution"
).sublist(
"Gumbel"
).get(
"Scale"
,1.);
39
checkInputs
(
loc_
,
scale_
);
40
}
41
42
Real
evaluatePDF
(
const
Real input)
const
{
43
Real z = (x-
loc_
)/
scale_
;
44
return
std::exp(-(z+exp(-z)))/
scale_
;
45
}
46
47
Real
evaluateCDF
(
const
Real input)
const
{
48
Real z = (x-
loc_
)/
scale_
;
49
return
std::exp(-std::exp(-z));
50
}
51
52
Real
integrateCDF
(
const
Real input)
const
{
53
throw
Exception::NotImplemented
(
">>> (Gumbel::integrateCDF): Not implemented!"
);
54
return
static_cast<
Real
>
(0);
55
}
56
57
Real
invertCDF
(
const
Real input)
const
{
58
return
loc_
-
scale_
*std::log(-std::log(input));
59
}
60
61
Real
moment
(
const
size_t
m)
const
{
62
Real val(0), gamma(0.57721566490153286);
63
if
(m==1) {
64
val =
loc_
+
scale_
*gamma;
65
}
66
else
if
(m==2) {
67
Real pi(M_PI), six(6);
68
val = std::pow(
scale_
*pi,2)/six + std::pow(
loc_
+
scale_
*gamma,2);
69
}
70
else
{
71
throw
Exception::NotImplemented
(
">>> (Gumbel::moment): Moment is only implemented for m=1,2!"
);
72
}
73
return
val;
74
}
75
76
Real
lowerBound
(
void
)
const
{
77
return
ROL_NINF<Real>
();
78
}
79
80
Real
upperBound
(
void
)
const
{
81
return
ROL_INF<Real>
();
82
}
83
84
void
test
(std::ostream &outStream = std::cout )
const
{
85
size_t
size = 3;
86
std::vector<Real> X(size,0.);
87
std::vector<int> T(size,0);
88
X[0] =
loc_
-4.0*(Real)rand()/(Real)RAND_MAX;
89
T[0] = 0;
90
X[1] =
loc_
;
91
T[1] = 1;
92
X[2] =
loc_
+4.0*(Real)rand()/(Real)RAND_MAX;
93
T[2] = 0;
94
Distribution<Real>::test
(X,T,outStream);
95
}
96
};
97
98
}
99
100
#endif
ROL_Distribution.hpp
ROL::Distribution
Definition
ROL_Distribution.hpp:21
ROL::Distribution::test
virtual void test(std::ostream &outStream=std::cout) const
Definition
ROL_Distribution.hpp:60
ROL::Exception::NotImplemented
Definition
ROL_Types.hpp:884
ROL::Gumbel::moment
Real moment(const size_t m) const
Definition
ROL_Gumbel.hpp:61
ROL::Gumbel::loc_
Real loc_
Definition
ROL_Gumbel.hpp:21
ROL::Gumbel::scale_
Real scale_
Definition
ROL_Gumbel.hpp:22
ROL::Gumbel::evaluateCDF
Real evaluateCDF(const Real input) const
Definition
ROL_Gumbel.hpp:47
ROL::Gumbel::test
void test(std::ostream &outStream=std::cout) const
Definition
ROL_Gumbel.hpp:84
ROL::Gumbel::Gumbel
Gumbel(const Real loc=0., const Real scale=1.)
Definition
ROL_Gumbel.hpp:31
ROL::Gumbel::integrateCDF
Real integrateCDF(const Real input) const
Definition
ROL_Gumbel.hpp:52
ROL::Gumbel::invertCDF
Real invertCDF(const Real input) const
Definition
ROL_Gumbel.hpp:57
ROL::Gumbel::checkInputs
void checkInputs(const Real loc, const Real scale) const
Definition
ROL_Gumbel.hpp:24
ROL::Gumbel::evaluatePDF
Real evaluatePDF(const Real input) const
Definition
ROL_Gumbel.hpp:42
ROL::Gumbel::upperBound
Real upperBound(void) const
Definition
ROL_Gumbel.hpp:80
ROL::Gumbel::Gumbel
Gumbel(ROL::ParameterList &parlist)
Definition
ROL_Gumbel.hpp:36
ROL::Gumbel::lowerBound
Real lowerBound(void) const
Definition
ROL_Gumbel.hpp:76
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_NINF
Real ROL_NINF(void)
Definition
ROL_Types.hpp:74
ROL::ROL_INF
Real ROL_INF(void)
Definition
ROL_Types.hpp:71
Generated by
1.17.0