BayesOpt
gauss_distribution.cpp
1 
2 #include <boost/math/special_functions/factorials.hpp>
3 #include "gauss_distribution.hpp"
4 
5 namespace bayesopt
6 {
7 
8  GaussianDistribution::GaussianDistribution(randEngine& eng):
9  ProbabilityDistribution(eng)
10  {
11  mean_ = 0.0; std_ = 1.0;
12  }
13 
14 
15  GaussianDistribution::~GaussianDistribution(){}
16 
18  size_t g)
19  {
20 
21  using boost::math::factorial;
22 
23  const double diff = min - mean_;
24  const double z = diff / std_;
25  const double pdf_z = boost::math::pdf(d_,z);
26  const double cdf_z = boost::math::cdf(d_,z);
27 
28  if (g == 1)
29  return -1.0 * ( diff * cdf_z + std_ * pdf_z );
30  else
31  {
32  const double fg = factorial<double>(g);
33 
34  double Tm2 = cdf_z;
35  double Tm1 = pdf_z;
36  double sumEI = pow(z,static_cast<double>(g))*Tm2 - g*pow(z,static_cast<double>(g-1))*Tm1;
37 
38  for (size_t ii = 2; ii < g; ++ii)
39  {
40  double Tact = (ii-1)*Tm2 - pdf_z*pow(z,static_cast<double>(ii-1));
41  sumEI += pow(-1.0,static_cast<double>(ii))*
42  (fg / ( factorial<double>(ii)*factorial<double>(g-ii) ) )*
43  pow(z,static_cast<double>(g-ii))*Tact;
44 
45  //roll-up
46  Tm2 = Tm1; Tm1 = Tact;
47  }
48  return -1.0 * pow(std_,static_cast<double>(g)) * sumEI;
49  }
50 
51  } // negativeExpectedImprovement
52 
54  {
55  return mean_ - beta*std_;
56  } // lowerConfidenceBound
57 
58 
60  double epsilon)
61  {
62  return -cdf(d_,(min - mean_ + epsilon)/std_);
63  } // negativeProbabilityOfImprovement
64 
65 
67  {
68  randNFloat sample(mtRandom,normalDist(mean_,std_));
69  return sample();
70  } // sample_query
71 
72 }
double negativeExpectedImprovement(double min, size_t g)
Expected Improvement algorithm for minimization.
Namespace of the library interface.
Definition: using.dox:1
double negativeProbabilityOfImprovement(double min, double epsilon)
Probability of improvement algorithm for minimization.
Gaussian probability distribution.
double sample_query()
Sample outcome acording to the marginal distribution at the query point.
double lowerConfidenceBound(double beta)
Lower confindence bound.