5#include <Infinity/api.h>
6#include <Infinity/Types/Math/Math.hpp>
14#include <initializer_list>
53 template<
typename RealType =
double>
56 static_assert(std::is_floating_point<RealType>::value,
57 "RealType must be a floating point type");
80 explicit param_type(RealType a, RealType b = RealType(1))
88 RealType
a()
const {
return m_a; }
91 RealType
b()
const {
return m_b; }
95 return lhs.m_a == rhs.m_a && lhs.m_b == rhs.m_b;
100 return !(lhs == rhs);
141 RealType
a()
const {
return m_param.a(); }
144 RealType
b()
const {
return m_param.b(); }
166 template<
typename Generator>
169 return (*
this)(g, m_param);
184 template<
typename Generator>
187 uint32_t random_bits;
188 using generator_result =
typename Generator::result_type;
190 if constexpr (
sizeof(generator_result) >=
sizeof(uint32_t))
192 random_bits =
static_cast<uint32_t
>(g());
194 constexpr int bits_per_call =
sizeof(generator_result) * 8;
195 constexpr int calls_needed = (32 + bits_per_call - 1) / bits_per_call;
197 for (
int i = 0; i < calls_needed; ++i)
199 random_bits = (random_bits << bits_per_call) | static_cast<uint32_t>(g());
203 RealType unit = uint32_to_real(random_bits);
204 return param.
a() + unit * (param.
b() - param.
a());
212 return lhs.m_param == rhs.m_param;
218 return !(lhs == rhs);
235 static result_type uint32_to_real(uint32_t value)
237 constexpr RealType scale = RealType(1.0) / RealType(4294967296.0);
238 return static_cast<RealType
>(value) * scale;
278 template<
typename IntType =
int>
281 static_assert(std::is_integral<IntType>::value,
282 "IntType must be an integral type");
304 explicit param_type(IntType a, IntType b = std::numeric_limits<IntType>::max())
312 IntType
a()
const {
return m_a; }
315 IntType
b()
const {
return m_b; }
319 return lhs.m_a == rhs.m_a && lhs.m_b == rhs.m_b;
324 return !(lhs == rhs);
365 IntType
a()
const {
return m_param.a(); }
368 IntType
b()
const {
return m_param.b(); }
390 template<
typename Generator>
393 return (*
this)(g, m_param);
412 template<
typename Generator>
415 using UIntType =
typename std::make_unsigned<IntType>::type;
417 const IntType a = param.
a();
418 const IntType b = param.
b();
420 if (a == b)
return a;
422 const UIntType range =
static_cast<UIntType
>(b) -
static_cast<UIntType
>(a);
424 using generator_result =
typename Generator::result_type;
426 if constexpr (
sizeof(generator_result) >=
sizeof(uint32_t))
428 x =
static_cast<uint32_t
>(g());
430 constexpr int bits_per_call =
sizeof(generator_result) * 8;
431 constexpr int calls_needed = (32 + bits_per_call - 1) / bits_per_call;
433 for (
int i = 0; i < calls_needed; ++i)
435 x = (x << bits_per_call) | static_cast<uint32_t>(g());
439 const UIntType range_plus_one = range + 1;
441 if ((range_plus_one & range) == 0)
443 return static_cast<IntType
>(
static_cast<UIntType
>(a) + (x & range));
447 uint64_t m =
static_cast<uint64_t
>(x) *
static_cast<uint64_t
>(range_plus_one);
448 uint32_t l =
static_cast<uint32_t
>(m);
450 if (l < range_plus_one)
452 uint32_t t = -range_plus_one % range_plus_one;
455 x =
static_cast<uint32_t
>(g());
456 m =
static_cast<uint64_t
>(x) *
static_cast<uint64_t
>(range_plus_one);
457 l =
static_cast<uint32_t
>(m);
461 return static_cast<IntType
>(
static_cast<UIntType
>(a) + (m >> 32));
469 return lhs.m_param == rhs.m_param;
475 return !(lhs == rhs);
522 template<
typename RealType =
double>
525 static_assert(std::is_floating_point<RealType>::value,
526 "RealType must be a floating point type");
547 explicit param_type(RealType mean, RealType stddev = RealType(1))
548 : m_mean(mean), m_stddev(stddev) { }
551 RealType
mean()
const {
return m_mean; }
554 RealType
stddev()
const {
return m_stddev; }
558 return lhs.m_mean == rhs.m_mean && lhs.m_stddev == rhs.m_stddev;
563 return !(lhs == rhs);
582 : m_param(mean, stddev), m_saved_available(false) {}
589 : m_param(param), m_saved_available(false) {}
597 void reset() { m_saved_available =
false; }
602 RealType
mean()
const {
return m_param.mean(); }
605 RealType
stddev()
const {
return m_param.stddev(); }
633 template<
typename Generator>
655 template<
typename Generator>
659 if (m_saved_available)
661 m_saved_available =
false;
662 return param.
mean() + m_saved * param.
stddev();
671 }
while (u1 == RealType(0));
676 const RealType magnitude = std::sqrt(-RealType(2) * std::log(u1));
682 m_saved_available =
true;
692 return lhs.m_param == rhs.m_param && lhs.m_saved_available == rhs.m_saved_available &&
693 (!lhs.m_saved_available || lhs.m_saved == rhs.m_saved);
698 return !(lhs == rhs);
703 result_type m_saved = RealType(0);
704 bool m_saved_available =
false;
743 template<
typename RealType =
double>
745 static_assert(std::is_floating_point<RealType>::value,
746 "RealType must be a floating point type");
768 explicit param_type(RealType m, RealType s = RealType(1)) : m_m(m), m_s(s) { }
771 RealType
m()
const {
return m_m; }
774 RealType
s()
const {
return m_s; }
778 return lhs.m_m == rhs.m_m && lhs.m_s == rhs.m_s;
782 return !(lhs == rhs);
800 : m_param(m, s), m_nd(m, s) { }
807 : m_param(param), m_nd(param.m(), param.s()) { }
819 RealType
m()
const {
return m_param.m(); }
822 RealType
s()
const {
return m_param.s(); }
844 template<
typename Generator>
858 template<
typename Generator>
862 return std::exp(nd(g));
869 return lhs.m_param == rhs.m_param && lhs.m_nd == rhs.m_nd;
873 return !(lhs == rhs);
921 template<
typename RealType =
double>
924 static_assert(std::is_floating_point<RealType>::value,
925 "RealType must be a floating point type");
946 explicit param_type(RealType a, RealType b = RealType(1)) : m_a(a), m_b(b) { }
949 RealType
a()
const {
return m_a; }
952 RealType
b()
const {
return m_b; }
956 return lhs.m_a == rhs.m_a && lhs.m_b == rhs.m_b;
960 return !(lhs == rhs);
995 RealType
a()
const {
return m_param.a(); }
998 RealType
b()
const {
return m_param.b(); }
1020 template<
typename Generator>
1034 template<
typename Generator>
1038 const RealType u = uniform(g);
1046 return lhs.m_param == rhs.m_param;
1050 return !(lhs == rhs);
1096 template<
typename RealType =
double>
1099 static_assert(std::is_floating_point<RealType>::value,
1100 "RealType must be a floating point type");
1123 : m_alpha(alpha), m_beta(beta) {}
1126 RealType
alpha()
const {
return m_alpha; }
1129 RealType
beta()
const {
return m_beta; }
1133 return lhs.m_alpha == rhs.m_alpha && lhs.m_beta == rhs.m_beta;
1137 return !(lhs == rhs);
1141 RealType m_alpha, m_beta;
1155 : m_param(alpha, beta), m_nd() { }
1162 : m_param(param), m_nd() { }
1174 RealType
alpha()
const {
return m_param.alpha(); }
1177 RealType
beta()
const {
return m_param.beta(); }
1199 template<
typename Generator>
1226 template<
typename Generator>
1229 const RealType alpha = param.
alpha();
1230 const RealType beta = param.
beta();
1232 if (alpha < RealType(1))
1236 RealType result = (*this)(g,
param_type(alpha + RealType(1), RealType(1)));
1238 return result * std::pow(uniform(g), RealType(1) / alpha) * beta;
1242 const RealType d = alpha - RealType(1) / RealType(3);
1243 const RealType c = RealType(1) / std::sqrt(RealType(9) * d);
1253 v = RealType(1) + c * x;
1254 }
while (v <= RealType(0));
1257 const RealType u = uniform(g);
1258 const RealType x_sq = x * x;
1261 if (u < RealType(1) - RealType(0.0331) * x_sq * x_sq)
1263 return d * v * beta;
1267 if (std::log(u) < RealType(0.5) * x_sq + d * (RealType(1) - v + std::log(v)))
1269 return d * v * beta;
1280 return lhs.m_param == rhs.m_param && lhs.m_nd == rhs.m_nd;
1284 return !(lhs == rhs);
1330 template<
typename RealType =
double>
1333 static_assert(std::is_floating_point<RealType>::value,
1334 "RealType must be a floating point type");
1357 RealType
n()
const {
return m_n; }
1361 return lhs.m_n == rhs.m_n;
1365 return !(lhs == rhs);
1404 if (m_gd) m_gd->reset();
1410 RealType
n()
const {
return m_param.n(); }
1447 template<
typename Generator>
1450 return RealType(2) * (*m_gd)(g);
1463 template<
typename Generator>
1467 return RealType(2) * gd(g);
1474 if (lhs.m_param != rhs.m_param)
return false;
1475 if ((lhs.m_gd ==
nullptr) != (rhs.m_gd ==
nullptr))
return false;
1476 if (lhs.m_gd && rhs.m_gd && *lhs.m_gd != *rhs.m_gd)
return false;
1481 return !(lhs == rhs);
1523 template<
typename RealType =
double>
1526 static_assert(std::is_floating_point<RealType>::value,
1527 "RealType must be a floating point type");
1549 explicit param_type(RealType m, RealType n = RealType(1)) : m_m(m), m_n(n) { }
1552 RealType
m()
const {
return m_m; }
1555 RealType
n()
const {
return m_n; }
1559 return lhs.m_m == rhs.m_m && lhs.m_n == rhs.m_n;
1563 return !(lhs == rhs);
1605 if (m_gd_x) m_gd_x->reset();
1606 if (m_gd_y) m_gd_y->reset();
1612 RealType
m()
const {
return m_param.m(); }
1615 RealType
n()
const {
return m_param.n(); }
1654 template<
typename Generator>
1657 const RealType x = (*m_gd_x)(g);
1658 const RealType y = (*m_gd_y)(g);
1659 return (x * m_param.n()) / (y * m_param.m());
1670 template<
typename Generator>
1675 const RealType x = gd_x(g);
1676 const RealType y = gd_y(g);
1677 return (x * param.
n()) / (y * param.
m());
1684 if (lhs.m_param != rhs.m_param)
return false;
1685 if ((lhs.m_gd_x ==
nullptr) != (rhs.m_gd_x ==
nullptr))
return false;
1686 if ((lhs.m_gd_y ==
nullptr) != (rhs.m_gd_y ==
nullptr))
return false;
1687 if (lhs.m_gd_x && rhs.m_gd_x && *lhs.m_gd_x != *rhs.m_gd_x)
return false;
1688 if (lhs.m_gd_y && rhs.m_gd_y && *lhs.m_gd_y != *rhs.m_gd_y)
return false;
1693 return !(lhs == rhs);
1740 template<
typename RealType =
double>
1743 static_assert(std::is_floating_point<RealType>::value,
1744 "RealType must be a floating point type");
1768 RealType
n()
const {
return m_n; }
1772 return lhs.m_n == rhs.m_n;
1776 return !(lhs == rhs);
1793 : m_param(n), m_nd()
1803 : m_param(param), m_nd()
1816 if (m_gd) m_gd->reset();
1822 RealType
n()
const {
return m_param.n(); }
1859 template<
typename Generator>
1862 const RealType z = m_nd(g);
1863 const RealType v = (*m_gd)(g);
1864 return z * std::sqrt(m_param.n() / v);
1875 template<
typename Generator>
1880 const RealType z = nd(g);
1881 const RealType v = gd(g);
1882 return z * std::sqrt(param.
n() / v);
1889 if (lhs.m_param != rhs.m_param)
return false;
1890 if (lhs.m_nd != rhs.m_nd)
return false;
1891 if ((lhs.m_gd ==
nullptr) != (rhs.m_gd ==
nullptr))
return false;
1892 if (lhs.m_gd && rhs.m_gd && *lhs.m_gd != *rhs.m_gd)
return false;
1897 return !(lhs == rhs);
1947 template<
typename RealType =
double>
1950 static_assert(std::is_floating_point<RealType>::value,
1951 "RealType must be a floating point type");
1979 return lhs.m_lambda == rhs.m_lambda;
1983 return !(lhs == rhs);
2017 RealType
lambda()
const {
return m_param.lambda(); }
2039 template<
typename Generator>
2055 template<
typename Generator>
2062 }
while (u == RealType(0) || u == RealType(1));
2064 return -std::log(RealType(1) - u) / param.
lambda();
2071 return lhs.m_param == rhs.m_param;
2075 return !(lhs == rhs);
2122 template<
typename RealType =
double>
2125 static_assert(std::is_floating_point<RealType>::value,
2126 "RealType must be a floating point type");
2148 explicit param_type(RealType a, RealType b = RealType(1)) : m_a(a), m_b(b) { }
2151 RealType
a()
const {
return m_a; }
2154 RealType
b()
const {
return m_b; }
2158 return lhs.m_a == rhs.m_a && lhs.m_b == rhs.m_b;
2162 return !(lhs == rhs);
2197 RealType
a()
const {
return m_param.a(); }
2200 RealType
b()
const {
return m_param.b(); }
2222 template<
typename Generator>
2236 template<
typename Generator>
2240 return param.
b() * std::pow(exp(g), RealType(1) / param.
a());
2247 return lhs.m_param == rhs.m_param;
2251 return !(lhs == rhs);
2298 template<
typename RealType =
double>
2301 static_assert(std::is_floating_point<RealType>::value,
2302 "RealType must be a floating point type");
2324 explicit param_type(RealType a, RealType b = RealType(1)) : m_a(a), m_b(b) { }
2327 RealType
a()
const {
return m_a; }
2330 RealType
b()
const {
return m_b; }
2334 return lhs.m_a == rhs.m_a && lhs.m_b == rhs.m_b;
2338 return !(lhs == rhs);
2373 RealType
a()
const {
return m_param.a(); }
2376 RealType
b()
const {
return m_param.b(); }
2398 template<
typename Generator>
2415 template<
typename Generator>
2422 }
while (u == RealType(0) || u == RealType(1));
2424 return param.
a() - param.
b() * std::log(-std::log(u));
2431 return lhs.m_param == rhs.m_param;
2435 return !(lhs == rhs);
2508 double p()
const {
return m_p; }
2512 return lhs.m_p == rhs.m_p;
2516 return !(lhs == rhs);
2550 double p()
const {
return m_param.p(); }
2572 template<
typename Generator>
2586 template<
typename Generator>
2590 return uniform(g) < param.
p();
2597 return lhs.m_param == rhs.m_param;
2601 return !(lhs == rhs);
2649 template<
typename IntType =
int>
2652 static_assert(std::is_integral<IntType>::value,
2653 "IntType must be an integral type");
2674 explicit param_type(IntType t,
double p = 0.5) : m_t(t), m_p(p) { }
2677 IntType
t()
const {
return m_t; }
2680 double p()
const {
return m_p; }
2684 return lhs.m_t == rhs.m_t && lhs.m_p == rhs.m_p;
2688 return !(lhs == rhs);
2707 : m_param(t, p), m_nd(nullptr)
2709 if (t * p >= 5.0 && t * (1.0 - p) >= 5.0)
2711 double mean = t * p;
2712 double stddev = std::sqrt(t * p * (1.0 - p));
2722 : m_param(param), m_nd(nullptr)
2724 IntType t = param.
t();
2725 double p = param.
p();
2726 if (t * p >= 5.0 && t * (1.0 - p) >= 5.0)
2728 double mean = t * p;
2729 double stddev = std::sqrt(t * p * (1.0 - p));
2741 if (m_nd) m_nd->reset();
2747 IntType
t()
const {
return m_param.t(); }
2750 double p()
const {
return m_param.p(); }
2767 IntType t = param.
t();
2768 double p = param.
p();
2769 if (t * p >= 5.0 && t * (1.0 - p) >= 5.0)
2771 double mean = t * p;
2772 double stddev = std::sqrt(t * p * (1.0 - p));
2791 template<
typename Generator>
2794 return (*
this)(g, m_param);
2815 template<
typename Generator>
2818 const IntType t = param.
t();
2819 const double p = param.
p();
2821 if (t * p >= 5.0 && t * (1.0 - p) >= 5.0)
2824 double mean = t * p;
2825 double stddev = std::sqrt(t * p * (1.0 - p));
2829 result =
static_cast<IntType
>(std::floor(nd(g) + 0.5));
2830 }
while (result < 0 || result > t);
2836 for (IntType i = 0; i < t; ++i)
2848 if (lhs.m_param != rhs.m_param)
return false;
2849 if ((lhs.m_nd ==
nullptr) != (rhs.m_nd ==
nullptr))
return false;
2850 if (lhs.m_nd && rhs.m_nd && *lhs.m_nd != *rhs.m_nd)
return false;
2855 return !(lhs == rhs);
2903 template<
typename IntType =
int>
2906 static_assert(std::is_integral<IntType>::value,
2907 "IntType must be an integral type");
2930 double p()
const {
return m_p; }
2934 return lhs.m_p == rhs.m_p;
2938 return !(lhs == rhs);
2972 double p()
const {
return m_param.p(); }
2994 template<
typename Generator>
3012 template<
typename Generator>
3019 }
while (u == 0.0 || u == 1.0);
3021 const double log_1_p = std::log(1.0 - param.
p());
3022 return static_cast<IntType
>(std::ceil(std::log(u) / log_1_p) - 1.0);
3029 return lhs.m_param == rhs.m_param;
3033 return !(lhs == rhs);
3081 template<
typename IntType =
int>
3084 static_assert(std::is_integral<IntType>::value,
3085 "IntType must be an integral type");
3108 double mean()
const {
return m_mean; }
3112 return lhs.m_mean == rhs.m_mean;
3116 return !(lhs == rhs);
3133 : m_param(mean), m_nd(nullptr)
3146 : m_param(param), m_nd(nullptr)
3148 if (param.
mean() >= 10.0)
3161 if (m_nd) m_nd->reset();
3167 double mean()
const {
return m_param.mean(); }
3184 if (param.
mean() >= 10.0)
3204 template<
typename Generator>
3207 return (*
this)(g, m_param);
3233 template<
typename Generator>
3236 const double mean = param.
mean();
3244 result =
static_cast<IntType
>(std::floor(nd(g) + 0.5));
3245 }
while (result < 0);
3250 const double l = std::exp(-mean);
3267 if (lhs.m_param != rhs.m_param)
return false;
3268 if ((lhs.m_nd ==
nullptr) != (rhs.m_nd ==
nullptr))
return false;
3269 if (lhs.m_nd && rhs.m_nd && *lhs.m_nd != *rhs.m_nd)
return false;
3274 return !(lhs == rhs);
3323 template<
typename IntType =
int>
3326 static_assert(std::is_integral<IntType>::value,
3327 "IntType must be an integral type");
3348 explicit param_type(IntType k,
double p = 0.5) : m_k(k), m_p(p) {}
3351 IntType
k()
const {
return m_k; }
3354 double p()
const {
return m_p; }
3358 return lhs.m_k == rhs.m_k && lhs.m_p == rhs.m_p;
3362 return !(lhs == rhs);
3403 if (m_gd) m_gd->reset();
3409 IntType
k()
const {
return m_param.k(); }
3412 double p()
const {
return m_param.p(); }
3445 template<
typename Generator>
3448 return (*
this)(g, m_param);
3469 template<
typename Generator>
3473 double gamma_variate = gd(g);
3482 if (lhs.m_param != rhs.m_param)
return false;
3483 if ((lhs.m_gd ==
nullptr) != (rhs.m_gd ==
nullptr))
return false;
3484 if (lhs.m_gd && rhs.m_gd && *lhs.m_gd != *rhs.m_gd)
return false;
3489 return !(lhs == rhs);
3540 template<
typename IntType =
int>
3543 static_assert(std::is_integral<IntType>::value,
3544 "IntType must be an integral type");
3571 template<
typename InputIterator>
3573 : m_prob(first, last), m_cp()
3586 : m_prob(wl.begin(), wl.end()), m_cp()
3603 template<
typename UnaryOperation>
3604 param_type(
size_t count,
double xmin,
double xmax, UnaryOperation fw)
3605 : m_prob(count), m_cp()
3607 const double delta = (xmax - xmin) / count;
3608 for (
size_t i = 0; i < count; ++i)
3610 m_prob[i] = fw(xmin + (i + 0.5) * delta);
3621 return m_prob.empty() ? std::vector<double>(1, 1.0) : m_prob;
3630 return !(lhs == rhs);
3647 m_prob.push_back(1.0);
3648 m_cp.push_back(1.0);
3654 for (
double p : m_prob)
3662 const double uniform = 1.0 / m_prob.size();
3663 for (
auto& p : m_prob)
3668 for (
auto& p : m_prob)
3675 m_cp.resize(m_prob.size());
3676 m_cp[0] = m_prob[0];
3677 for (
size_t i = 1; i < m_prob.size(); ++i)
3679 m_cp[i] = m_cp[i - 1] + m_prob[i];
3697 template<
typename InputIterator>
3699 : m_param(first, last) { }
3716 template<
typename UnaryOperation>
3718 : m_param(count, xmin, xmax, fw) { }
3755 return m_param.m_prob.empty() ? 0 :
3756 static_cast<result_type>(m_param.m_prob.size() - 1);
3767 template<
typename Generator>
3785 template<
typename Generator>
3789 const double u = uniform(g);
3792 auto it = std::lower_bound(param.
m_cp.begin(), param.
m_cp.end(), u);
3793 return static_cast<IntType
>(it - param.
m_cp.begin());
3800 return lhs.m_param == rhs.m_param;
3804 return !(lhs == rhs);
3857 template<
typename RealType =
double>
3860 static_assert(std::is_floating_point<RealType>::value,
3861 "RealType must be a floating point type");
3878 : m_int{RealType(0), RealType(1)}, m_den{1.0}, m_cp{1.0}
3893 template<
typename InputIteratorB,
typename InputIteratorW>
3895 InputIteratorW first_w)
3896 : m_int(first_b, last_b), m_den(), m_cp()
3899 if (m_int.size() < 2)
3901 m_int = {RealType(0), RealType(1)};
3907 m_den.resize(m_int.size() - 1);
3908 for (
size_t i = 0; i < m_den.size(); ++i, ++first_w)
3910 m_den[i] = *first_w;
3925 template<
typename UnaryOperation>
3926 param_type(std::initializer_list<RealType> bl, UnaryOperation fw)
3927 : m_int(bl.begin(), bl.end()), m_den(), m_cp()
3930 if (m_int.size() < 2)
3932 m_int = {RealType(0), RealType(1)};
3938 m_den.resize(m_int.size() - 1);
3939 for (
size_t i = 0; i < m_den.size(); ++i)
3941 const RealType x = (m_int[i] + m_int[i + 1]) / RealType(2);
3960 template<
typename UnaryOperation>
3961 param_type(
size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
3962 : m_int(nw + 1), m_den(nw), m_cp()
3965 const RealType delta = (xmax - xmin) / nw;
3966 for (
size_t i = 0; i <= nw; ++i)
3968 m_int[i] = xmin + i * delta;
3971 for (
size_t i = 0; i < nw; ++i)
3973 const RealType x = (m_int[i] + m_int[i + 1]) / RealType(2);
3986 if (m_int.empty()) {
3987 std::vector<RealType> result(2);
3988 result[0] = RealType(0);
3989 result[1] = RealType(1);
4001 return m_den.empty() ? std::vector<double>(1, 1.0) : m_den;
4010 return !(lhs == rhs);
4027 std::vector<double> areas(m_den.size());
4028 double total_area = 0.0;
4030 for (
size_t i = 0; i < m_den.size(); ++i)
4032 const double width =
static_cast<double>(m_int[i + 1] - m_int[i]);
4033 areas[i] = m_den[i] * width;
4034 total_area += areas[i];
4038 if (total_area == 0.0)
4040 for (
auto& d : m_den)
4044 total_area =
static_cast<double>(m_int.back() - m_int.front());
4047 for (
auto& d : m_den)
4053 m_cp.resize(m_den.size());
4054 m_cp[0] = m_den[0] *
static_cast<double>(m_int[1] - m_int[0]);
4055 for (
size_t i = 1; i < m_den.size(); ++i)
4057 const double width =
static_cast<double>(m_int[i + 1] - m_int[i]);
4058 m_cp[i] = m_cp[i - 1] + m_den[i] * width;
4078 template<
typename InputIteratorB,
typename InputIteratorW>
4080 InputIteratorW first_w)
4081 : m_param(first_b, last_b, first_w) { }
4089 template<
typename UnaryOperation>
4091 : m_param(bl, fw) { }
4101 template<
typename UnaryOperation>
4103 : m_param(nw, xmin, xmax, fw) { }
4121 std::vector<RealType>
intervals()
const {
return m_param.intervals(); }
4124 std::vector<double>
densities()
const {
return m_param.densities(); }
4135 return m_param.m_int.empty() ? RealType(0) : m_param.m_int.front();
4141 return m_param.m_int.empty() ? RealType(1) : m_param.m_int.back();
4152 template<
typename Generator>
4170 template<
typename Generator>
4174 const double u = uniform(g);
4177 auto it = std::lower_bound(param.
m_cp.begin(), param.
m_cp.end(), u);
4178 const size_t idx = it - param.
m_cp.begin();
4182 return interval_uniform(g);
4190 return lhs.m_param == rhs.m_param;
4195 return !(lhs == rhs);
4252 template<
typename RealType =
double>
4255 static_assert(std::is_floating_point<RealType>::value,
4256 "RealType must be a floating point type");
4273 : m_int{RealType(0), RealType(1)}, m_den{1.0, 1.0}, m_cp{1.0}, m_m{0.0}
4288 template<
typename InputIteratorB,
typename InputIteratorW>
4290 InputIteratorW first_w)
4291 : m_int(first_b, last_b), m_den(), m_cp(), m_m()
4294 if (m_int.size() < 2)
4296 m_int = {RealType(0), RealType(1)};
4303 m_den.resize(m_int.size());
4304 for (
size_t i = 0; i < m_den.size(); ++i, ++first_w)
4306 m_den[i] = *first_w;
4321 template<
typename UnaryOperation>
4322 param_type(std::initializer_list<RealType> bl, UnaryOperation fw)
4323 : m_int(bl.begin(), bl.end()), m_den(), m_cp(), m_m()
4326 if (m_int.size() < 2)
4328 m_int = {RealType(0), RealType(1)};
4335 m_den.resize(m_int.size());
4336 for (
size_t i = 0; i < m_den.size(); ++i)
4338 m_den[i] = fw(m_int[i]);
4356 template<
typename UnaryOperation>
4357 param_type(
size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
4358 : m_int(nw + 1), m_den(nw + 1), m_cp(), m_m()
4361 const RealType delta = (xmax - xmin) / nw;
4362 for (
size_t i = 0; i <= nw; ++i)
4364 m_int[i] = xmin + i * delta;
4365 m_den[i] = fw(m_int[i]);
4379 std::vector<RealType> result(2);
4380 result[0] = RealType(0);
4381 result[1] = RealType(1);
4393 return m_den.empty() ? std::vector<double>(2, 1.0) : m_den;
4402 return !(lhs == rhs);
4420 const size_t n = m_int.size() - 1;
4423 std::vector<double> areas(n);
4424 double total_area = 0.0;
4426 for (
size_t i = 0; i < n; ++i)
4428 const double width =
static_cast<double>(m_int[i + 1] - m_int[i]);
4429 areas[i] = 0.5 * width * (m_den[i] + m_den[i + 1]);
4430 total_area += areas[i];
4434 if (total_area == 0.0)
4436 for (
auto& d : m_den)
4440 for (
size_t i = 0; i < n; ++i)
4442 const double width =
static_cast<double>(m_int[i + 1] - m_int[i]);
4444 total_area += areas[i];
4448 for (
auto& d : m_den)
4452 for (
auto& a : areas)
4462 for (
size_t i = 1; i < n; ++i)
4464 m_cp[i] = m_cp[i - 1] + areas[i];
4469 for (
size_t i = 0; i < n; ++i)
4471 const double width =
static_cast<double>(m_int[i + 1] - m_int[i]);
4472 m_m[i] = (m_den[i + 1] - m_den[i]) / width;
4492 template<
typename InputIteratorB,
typename InputIteratorW>
4494 InputIteratorW first_w)
4495 : m_param(first_b, last_b, first_w) { }
4503 template<
typename UnaryOperation>
4505 : m_param(bl, fw) { }
4515 template<
typename UnaryOperation>
4517 : m_param(nw, xmin, xmax, fw) { }
4535 std::vector<RealType>
intervals()
const {
return m_param.intervals(); }
4538 std::vector<double>
densities()
const {
return m_param.densities(); }
4549 return m_param.m_int.empty() ? RealType(0) : m_param.m_int.front();
4555 return m_param.m_int.empty() ? RealType(1) : m_param.m_int.back();
4566 template<
typename Generator>
4588 template<
typename Generator>
4592 const double u = uniform(g);
4595 auto it = std::lower_bound(param.
m_cp.begin(), param.
m_cp.end(), u);
4596 const size_t idx = it - param.
m_cp.begin();
4599 const double cp_start = (idx == 0) ? 0.0 : param.
m_cp[idx - 1];
4600 const double u_local = u - cp_start;
4607 const double x0 =
static_cast<double>(param.
m_int[idx]);
4608 const double d0 = param.
m_den[idx];
4609 const double m = param.
m_m[idx];
4611 if (std::abs(m) < 1e-10)
4614 return static_cast<RealType
>(x0 + u_local / d0);
4617 const double discriminant = d0 * d0 + 2.0 * m * u_local;
4618 const double dx = (-d0 + std::sqrt(discriminant)) / m;
4619 return static_cast<RealType
>(x0 + dx);
4628 return lhs.m_param == rhs.m_param;
4633 return !(lhs == rhs);
Platform-independent Bernoulli distribution.
Definition PRNGDistribution.hpp:2486
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2556
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2573
result_type max() const
Gets the maximum value that can be generated (true).
Definition PRNGDistribution.hpp:2562
friend bool operator!=(const BernoulliDistribution &lhs, const BernoulliDistribution &rhs)
Definition PRNGDistribution.hpp:2599
friend bool operator==(const BernoulliDistribution &lhs, const BernoulliDistribution &rhs)
Definition PRNGDistribution.hpp:2595
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2553
result_type min() const
Gets the minimum value that can be generated (false).
Definition PRNGDistribution.hpp:2559
bool result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:2488
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:2587
BernoulliDistribution(double p)
Constructs a Bernoulli distribution with specified success probability.
Definition PRNGDistribution.hpp:2532
BernoulliDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2538
BernoulliDistribution()
Default constructor. Creates fair Bernoulli distribution (p=0.5).
Definition PRNGDistribution.hpp:2526
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2550
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2545
Platform-independent binomial distribution.
Definition PRNGDistribution.hpp:2651
IntType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:2656
IntType t() const
Gets the number of trials.
Definition PRNGDistribution.hpp:2747
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2739
result_type min() const
Gets the minimum value that can be generated (0).
Definition PRNGDistribution.hpp:2778
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2753
BinomialDistribution()
Default constructor. Creates single trial distribution (t=1, p=0.5).
Definition PRNGDistribution.hpp:2699
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:2816
result_type max() const
Gets the maximum value that can be generated (t).
Definition PRNGDistribution.hpp:2781
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2750
BinomialDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2721
friend bool operator!=(const BinomialDistribution &lhs, const BinomialDistribution &rhs)
Definition PRNGDistribution.hpp:2853
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2792
friend bool operator==(const BinomialDistribution &lhs, const BinomialDistribution &rhs)
Definition PRNGDistribution.hpp:2846
BinomialDistribution(IntType t, double p=0.5)
Constructs a binomial distribution with specified parameters.
Definition PRNGDistribution.hpp:2706
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2762
Platform-independent Cauchy (Lorentz) distribution.
Definition PRNGDistribution.hpp:923
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:1010
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:1001
friend bool operator!=(const CauchyDistribution &lhs, const CauchyDistribution &rhs)
Definition PRNGDistribution.hpp:1048
RealType a() const
Gets the location parameter.
Definition PRNGDistribution.hpp:995
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:990
CauchyDistribution(RealType a, RealType b=RealType(1))
Constructs a Cauchy distribution with specified parameters.
Definition PRNGDistribution.hpp:977
CauchyDistribution()
Default constructor. Creates standard Cauchy distribution (a=0, b=1).
Definition PRNGDistribution.hpp:970
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:1021
result_type min() const
Gets the theoretical minimum value (negative infinity).
Definition PRNGDistribution.hpp:1007
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:1004
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:998
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:928
CauchyDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:983
friend bool operator==(const CauchyDistribution &lhs, const CauchyDistribution &rhs)
Definition PRNGDistribution.hpp:1044
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:1035
Platform-independent chi-squared distribution.
Definition PRNGDistribution.hpp:1332
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:1402
ChiSquaredDistribution()
Default constructor. Creates ChiSquared(1) distribution.
Definition PRNGDistribution.hpp:1375
friend bool operator!=(const ChiSquaredDistribution &lhs, const ChiSquaredDistribution &rhs)
Definition PRNGDistribution.hpp:1479
ChiSquaredDistribution(RealType n)
Constructs a chi-squared distribution with specified degrees of freedom.
Definition PRNGDistribution.hpp:1381
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:1448
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:1464
ChiSquaredDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:1391
friend bool operator==(const ChiSquaredDistribution &lhs, const ChiSquaredDistribution &rhs)
Definition PRNGDistribution.hpp:1472
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:1430
RealType n() const
Gets the degrees of freedom.
Definition PRNGDistribution.hpp:1410
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:1433
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:1422
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:1413
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:1337
Platform-independent discrete distribution with arbitrary probabilities.
Definition PRNGDistribution.hpp:3542
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:3768
std::vector< double > probabilities() const
Returns the probability vector.
Definition PRNGDistribution.hpp:3739
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:3731
DiscreteDistribution(InputIterator first, InputIterator last)
Constructs from iterator range of weights.
Definition PRNGDistribution.hpp:3698
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:3742
DiscreteDistribution(std::initializer_list< double > wl)
Constructs from initializer list of weights.
Definition PRNGDistribution.hpp:3705
result_type min() const
Gets the minimum value that can be generated (0).
Definition PRNGDistribution.hpp:3748
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:3745
result_type max() const
Gets the maximum value that can be generated.
Definition PRNGDistribution.hpp:3754
DiscreteDistribution(size_t count, double xmin, double xmax, UnaryOperation fw)
Constructs from function evaluated at intervals.
Definition PRNGDistribution.hpp:3717
DiscreteDistribution()
Default constructor. Creates uniform distribution over {0}.
Definition PRNGDistribution.hpp:3689
friend bool operator==(const DiscreteDistribution &lhs, const DiscreteDistribution &rhs)
Definition PRNGDistribution.hpp:3798
DiscreteDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:3724
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:3786
IntType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:3547
friend bool operator!=(const DiscreteDistribution &lhs, const DiscreteDistribution &rhs)
Definition PRNGDistribution.hpp:3802
Platform-independent exponential distribution.
Definition PRNGDistribution.hpp:1949
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:2026
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:1954
ExponentialDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2005
ExponentialDistribution()
Default constructor. Creates Exponential(1) distribution.
Definition PRNGDistribution.hpp:1993
ExponentialDistribution(RealType lambda)
Constructs an exponential distribution with specified rate.
Definition PRNGDistribution.hpp:1999
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2040
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2012
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2023
friend bool operator!=(const ExponentialDistribution &lhs, const ExponentialDistribution &rhs)
Definition PRNGDistribution.hpp:2073
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:2056
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:2029
friend bool operator==(const ExponentialDistribution &lhs, const ExponentialDistribution &rhs)
Definition PRNGDistribution.hpp:2069
RealType lambda() const
Gets the rate parameter.
Definition PRNGDistribution.hpp:2017
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2020
Platform-independent extreme value (Gumbel) distribution.
Definition PRNGDistribution.hpp:2300
RealType a() const
Gets the location parameter.
Definition PRNGDistribution.hpp:2373
friend bool operator!=(const ExtremeValueDistribution &lhs, const ExtremeValueDistribution &rhs)
Definition PRNGDistribution.hpp:2433
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:2376
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2382
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:2416
ExtremeValueDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2361
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:2305
friend bool operator==(const ExtremeValueDistribution &lhs, const ExtremeValueDistribution &rhs)
Definition PRNGDistribution.hpp:2429
ExtremeValueDistribution()
Default constructor. Creates standard Gumbel distribution (a=0, b=1).
Definition PRNGDistribution.hpp:2348
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2379
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2368
ExtremeValueDistribution(RealType a, RealType b=RealType(1))
Constructs an extreme value distribution with specified parameters.
Definition PRNGDistribution.hpp:2355
result_type min() const
Gets the theoretical minimum value (negative infinity).
Definition PRNGDistribution.hpp:2385
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2399
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:2388
Platform-independent Fisher F-distribution.
Definition PRNGDistribution.hpp:1525
RealType n() const
Gets the denominator degrees of freedom.
Definition PRNGDistribution.hpp:1615
friend bool operator==(const FisherFDistribution &lhs, const FisherFDistribution &rhs)
Definition PRNGDistribution.hpp:1682
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:1637
RealType m() const
Gets the numerator degrees of freedom.
Definition PRNGDistribution.hpp:1612
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:1671
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:1618
FisherFDistribution(RealType m, RealType n=RealType(1))
Constructs an F-distribution with specified degrees of freedom.
Definition PRNGDistribution.hpp:1580
FisherFDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:1591
friend bool operator!=(const FisherFDistribution &lhs, const FisherFDistribution &rhs)
Definition PRNGDistribution.hpp:1691
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:1530
FisherFDistribution()
Default constructor. Creates F(1, 1) distribution.
Definition PRNGDistribution.hpp:1573
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:1655
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:1627
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:1603
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:1640
Platform-independent gamma distribution.
Definition PRNGDistribution.hpp:1098
GammaDistribution(RealType alpha, RealType beta=RealType(1))
Constructs a gamma distribution with specified parameters.
Definition PRNGDistribution.hpp:1154
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:1183
RealType alpha() const
Gets the shape parameter.
Definition PRNGDistribution.hpp:1174
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:1180
GammaDistribution()
Default constructor. Creates Gamma(1, 1) distribution.
Definition PRNGDistribution.hpp:1147
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:1169
friend bool operator!=(const GammaDistribution &lhs, const GammaDistribution &rhs)
Definition PRNGDistribution.hpp:1282
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:1200
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:1103
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:1186
GammaDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:1161
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:1227
friend bool operator==(const GammaDistribution &lhs, const GammaDistribution &rhs)
Definition PRNGDistribution.hpp:1278
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:1189
RealType beta() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:1177
Platform-independent geometric distribution.
Definition PRNGDistribution.hpp:2905
friend bool operator==(const GeometricDistribution &lhs, const GeometricDistribution &rhs)
Definition PRNGDistribution.hpp:3027
result_type min() const
Gets the minimum value that can be generated (0).
Definition PRNGDistribution.hpp:2981
IntType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:2910
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2967
GeometricDistribution()
Default constructor. Creates geometric distribution with p=0.5.
Definition PRNGDistribution.hpp:2948
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2978
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2995
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2972
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:3013
GeometricDistribution(double p)
Constructs a geometric distribution with specified success probability.
Definition PRNGDistribution.hpp:2954
GeometricDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2960
result_type max() const
Gets the theoretical maximum value (unbounded).
Definition PRNGDistribution.hpp:2984
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2975
friend bool operator!=(const GeometricDistribution &lhs, const GeometricDistribution &rhs)
Definition PRNGDistribution.hpp:3031
Platform-independent lognormal distribution.
Definition PRNGDistribution.hpp:744
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:831
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:749
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:825
friend bool operator!=(const LognormalDistribution &lhs, const LognormalDistribution &rhs)
Definition PRNGDistribution.hpp:871
RealType s() const
Gets the standard deviation parameter of underlying normal distribution.
Definition PRNGDistribution.hpp:822
RealType m() const
Gets the mean parameter of underlying normal distribution.
Definition PRNGDistribution.hpp:819
LognormalDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:806
LognormalDistribution()
Default constructor. Creates Lognormal(0, 1) distribution.
Definition PRNGDistribution.hpp:792
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:814
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:845
friend bool operator==(const LognormalDistribution &lhs, const LognormalDistribution &rhs)
Definition PRNGDistribution.hpp:867
result_type operator()(Generator &g, const param_type &p)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:859
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:828
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:834
LognormalDistribution(RealType m, RealType s=RealType(1))
Constructs a lognormal distribution with specified parameters.
Definition PRNGDistribution.hpp:799
Platform-independent negative binomial distribution.
Definition PRNGDistribution.hpp:3325
result_type max() const
Gets the theoretical maximum value (unbounded).
Definition PRNGDistribution.hpp:3435
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:3415
result_type min() const
Gets the minimum value that can be generated (0).
Definition PRNGDistribution.hpp:3432
IntType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:3330
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:3470
friend bool operator==(const NegativeBinomialDistribution &lhs, const NegativeBinomialDistribution &rhs)
Definition PRNGDistribution.hpp:3480
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:3424
friend bool operator!=(const NegativeBinomialDistribution &lhs, const NegativeBinomialDistribution &rhs)
Definition PRNGDistribution.hpp:3487
NegativeBinomialDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:3390
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:3401
IntType k() const
Gets the number of successes required.
Definition PRNGDistribution.hpp:3409
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:3446
NegativeBinomialDistribution()
Default constructor. Creates distribution with k=1, p=0.5 (geometric).
Definition PRNGDistribution.hpp:3373
NegativeBinomialDistribution(IntType k, double p=0.5)
Constructs a negative binomial distribution with specified parameters.
Definition PRNGDistribution.hpp:3380
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:3412
Platform-independent normal (Gaussian) distribution.
Definition PRNGDistribution.hpp:524
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:529
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:608
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:597
NormalDistribution()
Default constructor. Creates standard normal distribution (mean=0, stddev=1).
Definition PRNGDistribution.hpp:574
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:617
RealType mean() const
Gets the mean of the distribution.
Definition PRNGDistribution.hpp:602
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:634
result_type min() const
Gets the theoretical minimum value (negative infinity).
Definition PRNGDistribution.hpp:620
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:623
NormalDistribution(RealType mean, RealType stddev=RealType(1))
Constructs a normal distribution with specified parameters.
Definition PRNGDistribution.hpp:581
NormalDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:588
friend bool operator!=(const NormalDistribution &lhs, const NormalDistribution &rhs)
Definition PRNGDistribution.hpp:696
RealType stddev() const
Gets the standard deviation of the distribution.
Definition PRNGDistribution.hpp:605
friend bool operator==(const NormalDistribution &lhs, const NormalDistribution &rhs)
Definition PRNGDistribution.hpp:690
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:656
Platform-independent piecewise constant distribution.
Definition PRNGDistribution.hpp:3859
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:3864
PiecewiseConstantDistribution(std::initializer_list< RealType > bl, UnaryOperation fw)
Constructs from interval boundaries and weight function.
Definition PRNGDistribution.hpp:4090
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:4130
friend bool operator!=(const PiecewiseConstantDistribution &lhs, const PiecewiseConstantDistribution &rhs)
Definition PRNGDistribution.hpp:4192
PiecewiseConstantDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:4109
std::vector< double > densities() const
Returns the density values.
Definition PRNGDistribution.hpp:4124
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:4127
friend bool operator==(const PiecewiseConstantDistribution &lhs, const PiecewiseConstantDistribution &rhs)
Definition PRNGDistribution.hpp:4187
PiecewiseConstantDistribution(InputIteratorB first_b, InputIteratorB last_b, InputIteratorW first_w)
Constructs from interval boundaries and density weights.
Definition PRNGDistribution.hpp:4079
std::vector< RealType > intervals() const
Returns the interval boundaries.
Definition PRNGDistribution.hpp:4121
PiecewiseConstantDistribution()
Default constructor. Creates uniform distribution over [0, 1).
Definition PRNGDistribution.hpp:4068
result_type max() const
Gets the maximum value that can be generated.
Definition PRNGDistribution.hpp:4139
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:4153
PiecewiseConstantDistribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
Constructs with evenly-spaced intervals and weight function.
Definition PRNGDistribution.hpp:4102
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:4171
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:4116
result_type min() const
Gets the minimum value that can be generated.
Definition PRNGDistribution.hpp:4133
Platform-independent piecewise linear distribution.
Definition PRNGDistribution.hpp:4254
PiecewiseLinearDistribution(std::initializer_list< RealType > bl, UnaryOperation fw)
Constructs from interval boundaries and density function.
Definition PRNGDistribution.hpp:4504
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:4541
result_type min() const
Gets the minimum value that can be generated.
Definition PRNGDistribution.hpp:4547
std::vector< double > densities() const
Returns the density values at boundaries.
Definition PRNGDistribution.hpp:4538
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:4589
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:4567
friend bool operator==(const PiecewiseLinearDistribution &lhs, const PiecewiseLinearDistribution &rhs)
Definition PRNGDistribution.hpp:4625
PiecewiseLinearDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:4523
PiecewiseLinearDistribution(InputIteratorB first_b, InputIteratorB last_b, InputIteratorW first_w)
Constructs from interval boundaries and density values.
Definition PRNGDistribution.hpp:4493
PiecewiseLinearDistribution()
Default constructor. Creates uniform distribution over [0, 1).
Definition PRNGDistribution.hpp:4482
result_type max() const
Gets the maximum value that can be generated.
Definition PRNGDistribution.hpp:4553
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:4530
PiecewiseLinearDistribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
Constructs with evenly-spaced intervals and density function.
Definition PRNGDistribution.hpp:4516
friend bool operator!=(const PiecewiseLinearDistribution &lhs, const PiecewiseLinearDistribution &rhs)
Definition PRNGDistribution.hpp:4630
std::vector< RealType > intervals() const
Returns the interval boundaries.
Definition PRNGDistribution.hpp:4535
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:4544
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:4259
Platform-independent Poisson distribution.
Definition PRNGDistribution.hpp:3083
friend bool operator!=(const PoissonDistribution &lhs, const PoissonDistribution &rhs)
Definition PRNGDistribution.hpp:3272
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:3234
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:3179
PoissonDistribution(double mean)
Constructs a Poisson distribution with specified mean.
Definition PRNGDistribution.hpp:3132
double mean() const
Gets the mean (rate) parameter.
Definition PRNGDistribution.hpp:3167
friend bool operator==(const PoissonDistribution &lhs, const PoissonDistribution &rhs)
Definition PRNGDistribution.hpp:3265
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:3159
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:3170
PoissonDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:3145
IntType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:3088
result_type min() const
Gets the minimum value that can be generated (0).
Definition PRNGDistribution.hpp:3191
PoissonDistribution()
Default constructor. Creates Poisson distribution with mean=1.0.
Definition PRNGDistribution.hpp:3126
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:3205
result_type max() const
Gets the theoretical maximum value (unbounded).
Definition PRNGDistribution.hpp:3194
Platform-independent Student's t-distribution.
Definition PRNGDistribution.hpp:1742
StudentTDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:1802
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:1747
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:1813
StudentTDistribution(RealType n)
Constructs a t-distribution with specified degrees of freedom.
Definition PRNGDistribution.hpp:1792
StudentTDistribution()
Default constructor. Creates t(1) distribution (Cauchy).
Definition PRNGDistribution.hpp:1786
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:1825
friend bool operator!=(const StudentTDistribution &lhs, const StudentTDistribution &rhs)
Definition PRNGDistribution.hpp:1895
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:1860
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:1845
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:1834
result_type min() const
Gets the theoretical minimum value (negative infinity).
Definition PRNGDistribution.hpp:1842
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:1876
friend bool operator==(const StudentTDistribution &lhs, const StudentTDistribution &rhs)
Definition PRNGDistribution.hpp:1887
RealType n() const
Gets the degrees of freedom.
Definition PRNGDistribution.hpp:1822
Platform-independent Weibull distribution.
Definition PRNGDistribution.hpp:2124
friend bool operator==(const WeibullDistribution &lhs, const WeibullDistribution &rhs)
Definition PRNGDistribution.hpp:2245
RealType a() const
Gets the shape parameter.
Definition PRNGDistribution.hpp:2197
result_type min() const
Gets the minimum value that can be generated (approaches 0).
Definition PRNGDistribution.hpp:2209
WeibullDistribution()
Default constructor. Creates Weibull(1, 1) distribution.
Definition PRNGDistribution.hpp:2172
result_type max() const
Gets the theoretical maximum value (positive infinity).
Definition PRNGDistribution.hpp:2212
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:2200
result_type operator()(Generator &g)
Generates the next random value using stored parameters.
Definition PRNGDistribution.hpp:2223
void param(const param_type ¶m)
Sets new parameters for the distribution.
Definition PRNGDistribution.hpp:2206
friend bool operator!=(const WeibullDistribution &lhs, const WeibullDistribution &rhs)
Definition PRNGDistribution.hpp:2249
RealType result_type
The type of values produced by the distribution.
Definition PRNGDistribution.hpp:2129
result_type operator()(Generator &g, const param_type ¶m)
Generates the next random value using provided parameters.
Definition PRNGDistribution.hpp:2237
param_type param() const
Gets the current parameter set.
Definition PRNGDistribution.hpp:2203
WeibullDistribution(RealType a, RealType b=RealType(1))
Constructs a Weibull distribution with specified parameters.
Definition PRNGDistribution.hpp:2179
void reset()
Resets the distribution state.
Definition PRNGDistribution.hpp:2192
WeibullDistribution(const param_type ¶m)
Constructs from a parameter set.
Definition PRNGDistribution.hpp:2185
Definition BaseException.hpp:9
template class INFINITY_API_PUBLIC ExponentialDistribution< double >
Definition PRNGDistribution.cpp:23
template class INFINITY_API_PUBLIC UniformIntDistribution< unsigned int >
Definition PRNGDistribution.cpp:10
template class INFINITY_API_PUBLIC StudentTDistribution< float >
Definition PRNGDistribution.cpp:58
template class INFINITY_API_PUBLIC WeibullDistribution< double >
Definition PRNGDistribution.cpp:26
template class INFINITY_API_PUBLIC UniformIntDistribution< long long >
Definition PRNGDistribution.cpp:13
template class INFINITY_API_PUBLIC NegativeBinomialDistribution< unsigned int >
Definition PRNGDistribution.cpp:50
template class INFINITY_API_PUBLIC ExtremeValueDistribution< double >
Definition PRNGDistribution.cpp:29
template class INFINITY_API_PUBLIC PiecewiseLinearDistribution< float >
Definition PRNGDistribution.cpp:68
template class INFINITY_API_PUBLIC CauchyDistribution< double >
Definition PRNGDistribution.cpp:32
template class INFINITY_API_PUBLIC UniformIntDistribution< unsigned long long >
Definition PRNGDistribution.cpp:14
template class INFINITY_API_PUBLIC WeibullDistribution< float >
Definition PRNGDistribution.cpp:25
template class INFINITY_API_PUBLIC NegativeBinomialDistribution< int >
Definition PRNGDistribution.cpp:49
template class INFINITY_API_PUBLIC PoissonDistribution< unsigned int >
Definition PRNGDistribution.cpp:43
template class INFINITY_API_PUBLIC PoissonDistribution< long >
Definition PRNGDistribution.cpp:44
template class INFINITY_API_PUBLIC LognormalDistribution< float >
Definition PRNGDistribution.cpp:34
template class INFINITY_API_PUBLIC UniformIntDistribution< unsigned long >
Definition PRNGDistribution.cpp:12
template class INFINITY_API_PUBLIC GeometricDistribution< int >
Definition PRNGDistribution.cpp:37
template class INFINITY_API_PUBLIC DiscreteDistribution< unsigned int >
Definition PRNGDistribution.cpp:62
template class INFINITY_API_PUBLIC ChiSquaredDistribution< float >
Definition PRNGDistribution.cpp:52
template class INFINITY_API_PUBLIC FisherFDistribution< float >
Definition PRNGDistribution.cpp:55
template class INFINITY_API_PUBLIC PiecewiseLinearDistribution< double >
Definition PRNGDistribution.cpp:69
template class INFINITY_API_PUBLIC DiscreteDistribution< int >
Definition PRNGDistribution.cpp:61
template class INFINITY_API_PUBLIC BinomialDistribution< int >
Definition PRNGDistribution.cpp:46
template class INFINITY_API_PUBLIC UniformRealDistribution< double >
Definition PRNGDistribution.cpp:7
template class INFINITY_API_PUBLIC PiecewiseConstantDistribution< float >
Definition PRNGDistribution.cpp:65
template class INFINITY_API_PUBLIC CauchyDistribution< float >
Definition PRNGDistribution.cpp:31
template class INFINITY_API_PUBLIC NormalDistribution< float >
Definition PRNGDistribution.cpp:16
template class INFINITY_API_PUBLIC PoissonDistribution< int >
Definition PRNGDistribution.cpp:42
template class INFINITY_API_PUBLIC LognormalDistribution< double >
Definition PRNGDistribution.cpp:35
template class INFINITY_API_PUBLIC GeometricDistribution< unsigned int >
Definition PRNGDistribution.cpp:38
template class INFINITY_API_PUBLIC GammaDistribution< float >
Definition PRNGDistribution.cpp:19
template class INFINITY_API_PUBLIC NormalDistribution< double >
Definition PRNGDistribution.cpp:17
template class INFINITY_API_PUBLIC GammaDistribution< double >
Definition PRNGDistribution.cpp:20
template class INFINITY_API_PUBLIC DiscreteDistribution< long >
Definition PRNGDistribution.cpp:63
template class INFINITY_API_PUBLIC UniformIntDistribution< long >
Definition PRNGDistribution.cpp:11
template class INFINITY_API_PUBLIC UniformRealDistribution< float >
Definition PRNGDistribution.cpp:6
template class INFINITY_API_PUBLIC ExtremeValueDistribution< float >
Definition PRNGDistribution.cpp:28
template class INFINITY_API_PUBLIC GeometricDistribution< unsigned long >
Definition PRNGDistribution.cpp:40
template class INFINITY_API_PUBLIC UniformIntDistribution< int >
Definition PRNGDistribution.cpp:9
template class INFINITY_API_PUBLIC FisherFDistribution< double >
Definition PRNGDistribution.cpp:56
template class INFINITY_API_PUBLIC GeometricDistribution< long >
Definition PRNGDistribution.cpp:39
template class INFINITY_API_PUBLIC BinomialDistribution< unsigned int >
Definition PRNGDistribution.cpp:47
template class INFINITY_API_PUBLIC ChiSquaredDistribution< double >
Definition PRNGDistribution.cpp:53
template class INFINITY_API_PUBLIC PiecewiseConstantDistribution< double >
Definition PRNGDistribution.cpp:66
template class INFINITY_API_PUBLIC StudentTDistribution< double >
Definition PRNGDistribution.cpp:59
template class INFINITY_API_PUBLIC ExponentialDistribution< float >
Definition PRNGDistribution.cpp:22
constexpr float PI
Mathematical constants.
Definition Math.hpp:11
Parameter set for the distribution.
Definition PRNGDistribution.hpp:2495
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2514
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2508
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2510
param_type(double p)
Constructs parameters.
Definition PRNGDistribution.hpp:2505
param_type()
Default constructor. Creates parameters for fair coin (p=0.5).
Definition PRNGDistribution.hpp:2499
Parameter set for the distribution.
Definition PRNGDistribution.hpp:2663
param_type(IntType t, double p=0.5)
Constructs parameters.
Definition PRNGDistribution.hpp:2674
IntType t() const
Gets the number of trials.
Definition PRNGDistribution.hpp:2677
param_type()
Default constructor. Creates parameters for single trial (t=1, p=0.5).
Definition PRNGDistribution.hpp:2667
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2686
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2680
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2682
Parameter set for the distribution.
Definition PRNGDistribution.hpp:935
param_type()
Default constructor. Creates parameters for standard Cauchy (a=0, b=1).
Definition PRNGDistribution.hpp:939
param_type(RealType a, RealType b=RealType(1))
Constructs parameters.
Definition PRNGDistribution.hpp:946
RealType a() const
Gets the location parameter.
Definition PRNGDistribution.hpp:949
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:958
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:952
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:954
Parameter set for the distribution.
Definition PRNGDistribution.hpp:1344
RealType n() const
Gets the degrees of freedom.
Definition PRNGDistribution.hpp:1357
param_type()
Default constructor. Creates parameters for ChiSquared(1).
Definition PRNGDistribution.hpp:1348
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1363
param_type(RealType n)
Constructs parameters.
Definition PRNGDistribution.hpp:1354
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1359
Parameter set for the distribution.
Definition PRNGDistribution.hpp:3556
std::vector< double > m_cp
Cumulative probabilities for efficient sampling.
Definition PRNGDistribution.hpp:3634
param_type(std::initializer_list< double > wl)
Constructs from initializer list of weights.
Definition PRNGDistribution.hpp:3585
param_type(InputIterator first, InputIterator last)
Constructs from iterator range of weights.
Definition PRNGDistribution.hpp:3572
param_type(size_t count, double xmin, double xmax, UnaryOperation fw)
Constructs from function evaluated at intervals.
Definition PRNGDistribution.hpp:3604
std::vector< double > probabilities() const
Returns the probability vector.
Definition PRNGDistribution.hpp:3619
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3628
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3624
param_type()
Default constructor. Creates uniform distribution over {0}.
Definition PRNGDistribution.hpp:3560
std::vector< double > m_prob
Individual probabilities.
Definition PRNGDistribution.hpp:3633
Parameter set for the distribution.
Definition PRNGDistribution.hpp:1962
RealType lambda() const
Gets the rate parameter.
Definition PRNGDistribution.hpp:1975
param_type()
Default constructor. Creates parameters for Exponential(1).
Definition PRNGDistribution.hpp:1966
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1981
param_type(RealType lambda)
Constructs parameters.
Definition PRNGDistribution.hpp:1972
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1977
Parameter set for the distribution.
Definition PRNGDistribution.hpp:2313
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:2330
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2336
param_type(RealType a, RealType b=RealType(1))
Constructs parameters.
Definition PRNGDistribution.hpp:2324
RealType a() const
Gets the location parameter.
Definition PRNGDistribution.hpp:2327
param_type()
Default constructor. Creates parameters for standard Gumbel (a=0, b=1).
Definition PRNGDistribution.hpp:2317
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2332
Parameter set for the distribution.
Definition PRNGDistribution.hpp:1538
RealType m() const
Gets the numerator degrees of freedom.
Definition PRNGDistribution.hpp:1552
param_type(RealType m, RealType n=RealType(1))
Constructs parameters.
Definition PRNGDistribution.hpp:1549
RealType n() const
Gets the denominator degrees of freedom.
Definition PRNGDistribution.hpp:1555
param_type()
Default constructor. Creates parameters for F(1, 1).
Definition PRNGDistribution.hpp:1542
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1561
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1557
Parameter set for the distribution.
Definition PRNGDistribution.hpp:1111
param_type(RealType alpha, RealType beta=RealType(1))
Constructs parameters.
Definition PRNGDistribution.hpp:1122
RealType beta() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:1129
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1135
RealType alpha() const
Gets the shape parameter.
Definition PRNGDistribution.hpp:1126
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1131
param_type()
Default constructor. Creates parameters for Gamma(1, 1).
Definition PRNGDistribution.hpp:1115
Parameter set for the distribution.
Definition PRNGDistribution.hpp:2917
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:2930
param_type(double p)
Constructs parameters.
Definition PRNGDistribution.hpp:2927
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2936
param_type()
Default constructor. Creates parameters for p=0.5.
Definition PRNGDistribution.hpp:2921
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2932
Parameter set for the distribution.
Definition PRNGDistribution.hpp:757
param_type()
Default constructor. Creates parameters for Lognormal(0, 1).
Definition PRNGDistribution.hpp:761
RealType m() const
Gets the mean parameter of underlying normal distribution.
Definition PRNGDistribution.hpp:771
RealType s() const
Gets the standard deviation parameter of underlying normal distribution.
Definition PRNGDistribution.hpp:774
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:780
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:776
param_type(RealType m, RealType s=RealType(1))
Constructs parameters for underlying normal distribution.
Definition PRNGDistribution.hpp:768
Parameter set for the distribution.
Definition PRNGDistribution.hpp:3337
IntType k() const
Gets the number of successes required.
Definition PRNGDistribution.hpp:3351
param_type(IntType k, double p=0.5)
Constructs parameters.
Definition PRNGDistribution.hpp:3348
double p() const
Gets the success probability.
Definition PRNGDistribution.hpp:3354
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3360
param_type()
Default constructor. Creates parameters for k=1, p=0.5.
Definition PRNGDistribution.hpp:3341
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3356
Parameter set for the distribution.
Definition PRNGDistribution.hpp:536
param_type()
Default constructor. Creates parameters for standard normal (mean=0, stddev=1).
Definition PRNGDistribution.hpp:540
RealType stddev() const
Gets the standard deviation of the distribution.
Definition PRNGDistribution.hpp:554
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:561
param_type(RealType mean, RealType stddev=RealType(1))
Constructs parameters with specified mean and standard deviation.
Definition PRNGDistribution.hpp:547
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:556
RealType mean() const
Gets the mean of the distribution.
Definition PRNGDistribution.hpp:551
Parameter set for the distribution.
Definition PRNGDistribution.hpp:3873
std::vector< double > m_den
Normalized densities for each interval.
Definition PRNGDistribution.hpp:4014
std::vector< RealType > m_int
Interval boundaries.
Definition PRNGDistribution.hpp:4013
param_type(std::initializer_list< RealType > bl, UnaryOperation fw)
Constructs from interval boundaries and weight function.
Definition PRNGDistribution.hpp:3926
std::vector< double > m_cp
Cumulative probabilities for sampling.
Definition PRNGDistribution.hpp:4015
param_type(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
Constructs with evenly-spaced intervals and weight function.
Definition PRNGDistribution.hpp:3961
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:4008
std::vector< RealType > intervals() const
Returns the interval boundaries.
Definition PRNGDistribution.hpp:3984
param_type(InputIteratorB first_b, InputIteratorB last_b, InputIteratorW first_w)
Constructs from interval boundaries and density weights.
Definition PRNGDistribution.hpp:3894
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:4004
param_type()
Default constructor. Creates uniform distribution over [0, 1).
Definition PRNGDistribution.hpp:3877
std::vector< double > densities() const
Returns the density values for each interval.
Definition PRNGDistribution.hpp:3999
Parameter set for the distribution.
Definition PRNGDistribution.hpp:4268
std::vector< RealType > intervals() const
Returns the interval boundaries.
Definition PRNGDistribution.hpp:4375
param_type(InputIteratorB first_b, InputIteratorB last_b, InputIteratorW first_w)
Constructs from interval boundaries and density values.
Definition PRNGDistribution.hpp:4289
param_type(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw)
Constructs with evenly-spaced intervals and density function.
Definition PRNGDistribution.hpp:4357
std::vector< RealType > m_int
Interval boundaries.
Definition PRNGDistribution.hpp:4405
std::vector< double > densities() const
Returns the density values at boundaries.
Definition PRNGDistribution.hpp:4391
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:4400
std::vector< double > m_cp
Cumulative probabilities.
Definition PRNGDistribution.hpp:4407
param_type(std::initializer_list< RealType > bl, UnaryOperation fw)
Constructs from interval boundaries and density function.
Definition PRNGDistribution.hpp:4322
std::vector< double > m_den
Normalized densities at boundaries.
Definition PRNGDistribution.hpp:4406
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:4396
param_type()
Default constructor. Creates uniform distribution over [0, 1).
Definition PRNGDistribution.hpp:4272
std::vector< double > m_m
Slopes for each interval.
Definition PRNGDistribution.hpp:4408
Parameter set for the distribution.
Definition PRNGDistribution.hpp:3095
param_type(double mean)
Constructs parameters.
Definition PRNGDistribution.hpp:3105
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3114
param_type()
Default constructor. Creates parameters for mean=1.0.
Definition PRNGDistribution.hpp:3099
double mean() const
Gets the mean (rate) parameter.
Definition PRNGDistribution.hpp:3108
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:3110
Parameter set for the distribution.
Definition PRNGDistribution.hpp:1755
RealType n() const
Gets the degrees of freedom.
Definition PRNGDistribution.hpp:1768
param_type()
Default constructor. Creates parameters for t(1).
Definition PRNGDistribution.hpp:1759
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1774
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:1770
param_type(RealType n)
Constructs parameters.
Definition PRNGDistribution.hpp:1765
Parameter set for the distribution.
Definition PRNGDistribution.hpp:2137
RealType a() const
Gets the shape parameter.
Definition PRNGDistribution.hpp:2151
RealType b() const
Gets the scale parameter.
Definition PRNGDistribution.hpp:2154
param_type()
Default constructor. Creates parameters for Weibull(1, 1) (exponential).
Definition PRNGDistribution.hpp:2141
friend bool operator!=(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2160
param_type(RealType a, RealType b=RealType(1))
Constructs parameters.
Definition PRNGDistribution.hpp:2148
friend bool operator==(const param_type &lhs, const param_type &rhs)
Definition PRNGDistribution.hpp:2156