48 #include "Teuchos_ParameterList.hpp" 65 pts_.clear(); pts_.resize(20,0.); wts_.clear(); wts_.resize(20,0.);
66 wts_[0] = 0.1527533871307258; pts_[0] = -0.0765265211334973;
67 wts_[1] = 0.1527533871307258; pts_[1] = 0.0765265211334973;
68 wts_[2] = 0.1491729864726037; pts_[2] = -0.2277858511416451;
69 wts_[3] = 0.1491729864726037; pts_[3] = 0.2277858511416451;
70 wts_[4] = 0.1420961093183820; pts_[4] = -0.3737060887154195;
71 wts_[5] = 0.1420961093183820; pts_[5] = 0.3737060887154195;
72 wts_[6] = 0.1316886384491766; pts_[6] = -0.5108670019508271;
73 wts_[7] = 0.1316886384491766; pts_[7] = 0.5108670019508271;
74 wts_[8] = 0.1181945319615184; pts_[8] = -0.6360536807265150;
75 wts_[9] = 0.1181945319615184; pts_[9] = 0.6360536807265150;
76 wts_[10] = 0.1019301198172404; pts_[10] = -0.7463319064601508;
77 wts_[11] = 0.1019301198172404; pts_[11] = 0.7463319064601508;
78 wts_[12] = 0.0832767415767048; pts_[12] = -0.8391169718222188;
79 wts_[13] = 0.0832767415767048; pts_[13] = 0.8391169718222188;
80 wts_[14] = 0.0626720483341091; pts_[14] = -0.9122344282513259;
81 wts_[15] = 0.0626720483341091; pts_[15] = 0.9122344282513259;
82 wts_[16] = 0.0406014298003869; pts_[16] = -0.9639719272779138;
83 wts_[17] = 0.0406014298003869; pts_[17] = 0.9639719272779138;
84 wts_[18] = 0.0176140071391521; pts_[18] = -0.9931285991850949;
85 wts_[19] = 0.0176140071391521; pts_[19] = 0.9931285991850949;
86 for (
size_t i = 0; i < 20; i++) {
88 pts_[i] += 1.; pts_[i] *= 0.5;
92 Real
ibeta(
const Real x)
const {
93 Real pt = 0., wt = 0., sum = 0.;
94 for (
size_t i = 0; i < pts_.size(); i++) {
97 sum += wt*std::pow(pt,shape1_-1)*std::pow(1.-pt,shape2_-1);
103 Beta(
const Real shape1 = 2.,
const Real shape2 = 2.)
104 : shape1_((shape1 > 0.) ? shape1 : 2.), shape2_((shape2 > 0.) ? shape2 : 2.) {
105 coeff_ = tgamma(shape1_+shape2_)/(tgamma(shape1_)*tgamma(shape2_));
109 Beta(Teuchos::ParameterList &parlist) {
110 shape1_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Beta").get(
"Shape 1",2.);
111 shape2_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Beta").get(
"Shape 2",2.);
112 shape1_ = (shape1_ > 0.) ? shape1_ : 2.;
113 shape2_ = (shape2_ > 0.) ? shape2_ : 2.;
114 coeff_ = tgamma(shape1_+shape2_)/(tgamma(shape1_)*tgamma(shape2_));
119 return ((input > 0.) ? ((input < 1.) ?
120 coeff_*std::pow(input,shape1_-1.)*std::pow(1.-input,shape2_-1) : 0.) : 0.);
124 return ((input > 0.) ? ((input < 1.) ? coeff_*
ibeta(input) : 1.) : 0.);
128 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
129 ">>> ERROR (ROL::Beta): Beta integrateCDF not implemented!");
130 return ((input < 0.) ? 0. : input);
143 Real sa = ((fa < 0.) ? -1. : ((fa > 0.) ? 1. : 0.));
145 for (
size_t i = 0; i < 100; i++) {
148 sc = ((fc < 0.) ? -1. : ((fc > 0.) ? 1. : 0.));
152 if ( sc == sa ) { a = c; fa = fc; sa = sc; }
160 return shape1_/(shape1_ +
shape2_);
163 return shape1_*(shape2_/(shape1_+shape2_+1.) +
shape1_)/std::pow(shape1_+shape2_,2);
166 for (
size_t i = 0; i < m; i++) {
167 val *= (shape1_ + (Real)i)/(shape1_ + shape2_ + (Real)i);
180 void test(std::ostream &outStream = std::cout )
const {
182 std::vector<Real> X(size,0.);
183 std::vector<int> T(size,0);
184 X[0] = -4.*(Real)rand()/(Real)RAND_MAX;
188 X[2] = 0.5*(Real)rand()/(Real)RAND_MAX;
192 X[4] = 1.+4.*(Real)rand()/(Real)RAND_MAX;
Real evaluatePDF(const Real input) const
Beta(const Real shape1=2., const Real shape2=2.)
Real integrateCDF(const Real input) const
Real ibeta(const Real x) const
void initializeQuadrature(void)
Real lowerBound(void) const
void test(std::ostream &outStream=std::cout) const
Real upperBound(void) const
virtual void test(std::ostream &outStream=std::cout) const
Real evaluateCDF(const Real input) const
Beta(Teuchos::ParameterList &parlist)
Real moment(const size_t m) const
Real invertCDF(const Real input) const
static const double ROL_EPSILON
Platform-dependent machine epsilon.