ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
distribution
ROL_Logistic.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_LOGISTIC_HPP
11
#define ROL_LOGISTIC_HPP
12
13
#include "
ROL_Distribution.hpp
"
14
#include "ROL_ParameterList.hpp"
15
16
namespace
ROL
{
17
18
template
<
class
Real>
19
class
Logistic
:
public
Distribution
<Real> {
20
private
:
21
Real
mean_
;
22
Real
var_
;
23
24
public
:
25
Logistic
(
const
Real mean = 0.,
const
Real var = 1.)
26
:
mean_
(mean),
var_
((var>0.) ? var : 1.) {}
27
28
Logistic
(ROL::ParameterList &parlist) {
29
mean_
= parlist.sublist(
"SOL"
).sublist(
"Distribution"
).sublist(
"Logistic"
).get(
"Mean"
,0.);
30
var_
= parlist.sublist(
"SOL"
).sublist(
"Distribution"
).sublist(
"Logistic"
).get(
"Scale"
,1.);
31
var_
= (
var_
> 0.) ?
var_
: 1.;
32
}
33
34
Real
evaluatePDF
(
const
Real input)
const
{
35
Real val = std::exp(-(input-
mean_
)/
var_
);
36
return
val/(
var_
*std::pow(1.0+val,2.0));
37
}
38
39
Real
evaluateCDF
(
const
Real input)
const
{
40
Real val = std::exp(-(input-
mean_
)/
var_
);
41
return
1.0/(1.0+val);
42
}
43
44
Real
integrateCDF
(
const
Real input)
const
{
45
Real val = std::exp(-(input-
mean_
)/
var_
);
46
return
(input-
mean_
) +
var_
*std::log(1.0+val);
47
}
48
49
Real
invertCDF
(
const
Real input)
const
{
50
return
mean_
+
var_
*std::log(input/(1.0-input));
51
}
52
53
Real
moment
(
const
size_t
m)
const
{
54
Real val = 0.;
55
switch
(m) {
56
case
1: val =
mean_
;
break
;
57
case
2: val = std::pow(
var_
*
ROL::ScalarTraits<Real>::pi
(),2)/3. + std::pow(
mean_
,2);
break
;
58
default
:
59
ROL_TEST_FOR_EXCEPTION(
true
, std::invalid_argument,
60
">>> ERROR (ROL::Logistic): Logistic moment not implemented for m > 2!"
);
61
}
62
return
val;
63
}
64
65
Real
lowerBound
(
void
)
const
{
66
return
ROL_NINF<Real>
();
67
}
68
69
Real
upperBound
(
void
)
const
{
70
return
ROL_INF<Real>
();
71
}
72
73
void
test
(std::ostream &outStream = std::cout )
const
{
74
size_t
size = 1;
75
std::vector<Real> X(size,4.*(Real)rand()/(Real)RAND_MAX - 2.);
76
std::vector<int> T(size,0);
77
Distribution<Real>::test
(X,T,outStream);
78
}
79
};
80
81
}
82
83
#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::Logistic::integrateCDF
Real integrateCDF(const Real input) const
Definition
ROL_Logistic.hpp:44
ROL::Logistic::evaluatePDF
Real evaluatePDF(const Real input) const
Definition
ROL_Logistic.hpp:34
ROL::Logistic::Logistic
Logistic(ROL::ParameterList &parlist)
Definition
ROL_Logistic.hpp:28
ROL::Logistic::lowerBound
Real lowerBound(void) const
Definition
ROL_Logistic.hpp:65
ROL::Logistic::invertCDF
Real invertCDF(const Real input) const
Definition
ROL_Logistic.hpp:49
ROL::Logistic::upperBound
Real upperBound(void) const
Definition
ROL_Logistic.hpp:69
ROL::Logistic::mean_
Real mean_
Definition
ROL_Logistic.hpp:21
ROL::Logistic::var_
Real var_
Definition
ROL_Logistic.hpp:22
ROL::Logistic::Logistic
Logistic(const Real mean=0., const Real var=1.)
Definition
ROL_Logistic.hpp:25
ROL::Logistic::test
void test(std::ostream &outStream=std::cout) const
Definition
ROL_Logistic.hpp:73
ROL::Logistic::moment
Real moment(const size_t m) const
Definition
ROL_Logistic.hpp:53
ROL::Logistic::evaluateCDF
Real evaluateCDF(const Real input) const
Definition
ROL_Logistic.hpp:39
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
ROL::ROL::ScalarTraits::pi
static constexpr Real pi() noexcept
Definition
ROL_Constraint_SerialSimOpt.hpp:58
Generated by
1.17.0