Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
FlatMarginal.h
Go to the documentation of this file.
1#ifndef STANDARD_FLAT_H
2#define STANDARD_FLAT_H
3
4#include <random>
5#include <cmath>
6#include <limits>
7#include <stdexcept>
8
10#include "Include.h"
11#include "AbstractConfig.h"
12
27 using gsl_rng_sptr = std::unique_ptr<gsl_rng, decltype(&gsl_rng_free)>;
28
39 double a;
40 double b;
41
43 FlatMarginalCfg() = default;
44
50 FlatMarginalCfg(double a, double b) : a(a), b(b) {}
51};
52
75class FlatMarginal final : public IMarginalDistribution {
76public:
84 explicit FlatMarginal(double a, double b, unsigned int seed = std::random_device{}());
85
87 std::vector<double> rvs(std::size_t n) override;
88
90 double logpdf(double x) override;
91
92 PDFDiff f_df_ddf(double x) override;
93
95 double cdf(double x) override;
96
98 double ppf(double p) override;
99
101 double mean() override;
102
104 double std() override;
105
106private:
107 double a, b;
108 const gsl_rng_type* rng_tp {gsl_rng_mt19937};
109 gsl_rng_sptr eng_{gsl_rng_alloc(rng_tp), &gsl_rng_free};
110};
111
112#endif
Base type for lightweight configuration structures.
std::unique_ptr< gsl_rng, decltype(&gsl_rng_free)> gsl_rng_sptr
std::unique_ptr< gsl_rng, decltype(&gsl_rng_free)> gsl_rng_sptr
Interface for one-dimensional marginal probability distributions.
Continuous uniform marginal distribution on [a,b].
double ppf(double p) override
Evaluates the quantile function (inverse CDF).
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.
Polymorphic base class for configuration types.
Configuration object for FlatMarginal.
double b
Lower bound of the support.
FlatMarginalCfg(double a, double b)
Constructs a flat marginal configuration.
FlatMarginalCfg()=default
Upper bound of the support.
Abstract interface for scalar marginal distributions.