10 #if !defined(EXRANDOM_AUX_INFO_HPP) 11 #define EXRANDOM_AUX_INFO_HPP 1 33 static double pi() {
return std::atan2(0.0, -1.0); }
42 {
return x < 0 ? 0 : x < 1 ? x : 1; }
51 return x > 0 ? -std::expm1(-x) : 0;
61 {
return std::erf(x / std::sqrt(2.0)) / 2; }
91 for (
int k = -std::numeric_limits<double>::digits - 4;; ++k) {
108 for (
int k = -std::numeric_limits<double>::digits - 4;; ++k) {
111 if (!(y1 < 1))
break;
124 template <
typename param_type>
127 double mu = p.mu_num() / double( p.mu_den () ),
128 sigma = p.sigma_num() / double( p.sigma_den () ),
130 return std::exp( - x * x / 2) / norm;
138 template <
typename param_type>
140 int imu = p.mu_num() / p.mu_den(),
141 isig = ( p.sigma_num() + p.sigma_den() - 1 ) / p.sigma_den();
145 for (
int i = imu - 10 * isig; i < imu + 10 * isig; ++i) {
149 H -= P * std::log(P);
151 H = H/s + std::log(s);
154 double sigma = p.sigma_num() / double(p.sigma_den());
155 s = std::sqrt(2 *
pi()) * sigma;
156 H = std::log(s) + 0.5;
164 #endif // EXRANDOM_AUX_INFO_HPP static double uniform_mean_exponent()
static double discrete_normal_norm(const param_type &p, double &H)
static double uniform_entropy()
static double cumulative_normal(double x)
static double cumulative_exponential(double x)
static double normal_mean_exponent()
static double cumulative_uniform(double x)
Configuration for exrandom.
static double exponential_mean_exponent()
static double discrete_normal_prob(const param_type &p, int i, double norm=1)
Some auxiliary functions related to normal and exponential distributions.
static double normal_entropy()
static double exponential_entropy()