6 if (!std::isfinite(a) || !std::isfinite(b) || !(a < b)) {
7 throw std::invalid_argument(
"FlatMarginal requires finite bounds with a < b");
10 throw std::runtime_error(
"FlatMarginal could not allocate its GSL RNG");
12 gsl_rng_set(eng_.get(), seed);
16 std::vector<double> z(n);
17 for (std::size_t i = 0; i < n; ++i)
18 z[i] = gsl_ran_flat(eng_.get(), a, b);
26 return (x >= a && x <= b)
28 : -std::numeric_limits<double>::infinity();
32 const double pdf = (x >= a && x <= b) ? 1.0 / (b - a) : 0.0;
33 return {pdf, 0.0, 0.0};
37 return gsl_cdf_flat_P(x, a, b);
41 return gsl_cdf_flat_Pinv(p, a, b);
49 return (b - a) / std::sqrt(12.);
double ppf(double p) override
Evaluates the quantile function (inverse CDF).
FlatMarginal(double a, double b, unsigned int seed=std::random_device{}())
Constructs a uniform marginal on [a,b].
double logpdf(double x) override
Evaluates the logarithm of the probability density at x.
std::vector< double > rvs(std::size_t n) override
Draws random samples from the marginal distribution.
double cdf(double x) override
Evaluates the cumulative distribution function at x.
double mean() override
Returns the mean of the distribution.
PDFDiff f_df_ddf(double x) override
double std() override
Returns the standard deviation of the distribution.