23 static constexpr int n = 30;
25 static constexpr std::array<double, n> table = [] {
26 std::array<double, n> powers{};
28 for (
double &p : powers)
35 [[nodiscard]] std::string
Name()
const override;
37 [[nodiscard]]
double MinValue()
const override {
return 0; }
38 [[nodiscard]]
double MaxValue()
const override {
return 1; }
40 [[nodiscard]]
double F(
const double &x)
const override;
41 template <std::uniform_random_bit_generator G>
44 [[nodiscard]]
long double Mean()
const override;
45 [[nodiscard]]
long double Variance()
const override;
46 [[nodiscard]]
double Median()
const override;
47 [[nodiscard]]
long double Skewness()
const override;
51 double quantileImpl(
double p,
double initValue)
const override;
52 double quantileImpl(
double p)
const override;
53 double quantileImpl1m(
double p,
double initValue)
const override;
54 double quantileImpl1m(
double p)
const override;
56 std::complex<double> CFImpl(
double t)
const override;
82 double a = 0.0, b = 1.0;
83 double v = 0.5, d = 0.5, delta = 1.0;
85 delta = (b - a) / 3.0;
90 }
else if (x > b - delta) {
100template <std::uniform_random_bit_generator G>
103 long double sum = 0.0;
104 for (
int i = 0; i != n; ++i) {
120inline double CantorRand::quantileImpl(
double p,
double)
const
122 return math::findRoot([
this, p](
double x) {
return F(x) - p; }, 0.0, 1.0);
125inline double CantorRand::quantileImpl(
double p)
const
127 return quantileImpl(p, p);
130inline double CantorRand::quantileImpl1m(
double p,
double)
const
132 return math::findRoot([
this, p](
double x) {
return S(x) - p; }, 0.0, 1.0);
135inline double CantorRand::quantileImpl1m(
double p)
const
137 return quantileImpl1m(p, 1.0 - p);
140inline std::complex<double> CantorRand::CFImpl(
double t)
const
143 for (
int i = 0; i != n; ++i)
144 prod *= std::cos(t * table[i]);
145 std::complex<double> y(0.0, 0.5 * t);
static int StandardVariate(G &g)
Definition bernoulli.hpp:106
The CantorRand class Cantor distribution.
Definition cantor.hpp:20
long double Skewness() const override
Definition cantor.hpp:155
long double Mean() const override
Definition cantor.hpp:110
CantorRand()
Definition cantor.hpp:67
double F(const double &x) const override
Definition cantor.hpp:76
double MaxValue() const override
Definition cantor.hpp:38
double MinValue() const override
Definition cantor.hpp:37
Support SupportType() const override
Definition cantor.hpp:36
long double ExcessKurtosis() const override
Definition cantor.hpp:160
double Median() const override
Definition cantor.hpp:150
long double Variance() const override
Definition cantor.hpp:115
double operator()(G &g) const
Definition cantor.hpp:101
std::string Name() const override
Definition cantor.hpp:71
virtual double S(const T &x) const
Definition distribution.hpp:197
The SingularDistribution class Abstract class for all singular distributions.
Definition singular.hpp:18
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
constexpr long double minimumTolerance
Definition constants.hpp:44
Real findRoot(const F &f, std::type_identity_t< Real > a, std::type_identity_t< Real > b, int maxIterations=200)
Definition roots.hpp:205
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15