Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LikelihoodMarginal.h
Go to the documentation of this file.
1#ifndef LIKELIHOOD_DISCRETE_H
2#define LIKELIHOOD_DISCRETE_H
3
4#include <random>
5#include <vector>
6#include <numeric>
7#include <stdexcept>
8#include <cmath>
9
11#include "AbstractConfig.h"
12
39 std::vector<double> values;
40 std::vector<double> weights;
41};
42
64public:
80 LikelihoodMarginal(std::vector<double> values,
81 std::vector<double> weights,
82 unsigned int seed = std::random_device{}(),
83 bool standardize = false);
84
86 std::vector<double> rvs(std::size_t n) override;
87
89 double logpdf(double) override {
90 throw std::logic_error("LikelihoodMarginal::logpdf is not implemented");
91 }
92
94 PDFDiff f_df_ddf(double) override {
95 throw std::logic_error("LikelihoodMarginal::f_df_ddf is not implemented");
96 }
97
100 double cdf(double) override {
101 throw std::logic_error("LikelihoodMarginal::cdf is not implemented");
102 }
103
105 double ppf(double) override {
106 throw std::logic_error("LikelihoodMarginal::ppf is not implemented");
107 }
108
110 double mean() override {
111 throw std::logic_error("LikelihoodMarginal::mean is not implemented");
112 }
113
115 double std() override {
116 throw std::logic_error("LikelihoodMarginal::std is not implemented");
117 }
118
119private:
125 void build_alias_tables(std::vector<double> weights);
126
127 std::mt19937 eng_;
128 std::uniform_real_distribution<double> u01_;
129 std::vector<double> values_;
130
131 std::vector<double> prob_;
132 std::vector<std::size_t> alias_;
133
134 bool standardize_;
135 double mean_ = 0.0;
136 double std_ = 1.0;
137};
138
139#endif
Base type for lightweight configuration structures.
Interface for one-dimensional marginal probability distributions.
Discrete marginal sampler using Vose's alias method.
double logpdf(double) override
Not implemented; use this class only for sampling.
double ppf(double) override
Not implemented; use this class only for sampling.
std::vector< double > rvs(std::size_t n) override
Draws random samples from the marginal distribution.
double mean() override
Not implemented; use this class only for sampling.
double cdf(double) override
Not implemented; use this class only for sampling.
double std() override
Not implemented; use this class only for sampling.
PDFDiff f_df_ddf(double) override
Not implemented; use this class only for sampling.
Polymorphic base class for configuration types.
Abstract interface for scalar marginal distributions.
Configuration object for LikelihoodMarginal.
std::vector< double > values
std::vector< double > weights
Support points of the discrete distribution.