Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LikelihoodMarginal Class Referencefinal

Discrete marginal sampler using Vose's alias method. More...

#include <LikelihoodMarginal.h>

Inheritance diagram for LikelihoodMarginal:
Collaboration diagram for LikelihoodMarginal:

Public Member Functions

 LikelihoodMarginal (std::vector< double > values, std::vector< double > weights, unsigned int seed=std::random_device{}(), bool standardize=false)
 Constructs a discrete likelihood marginal.
 
std::vector< double > rvs (std::size_t n) override
 Draws random samples from the marginal distribution.
 
double logpdf (double) override
 Not implemented; use this class only for sampling.
 
PDFDiff f_df_ddf (double) override
 Not implemented; use this class only for sampling.
 
double cdf (double) override
 Not implemented; use this class only for sampling.
 
double ppf (double) override
 Not implemented; use this class only for sampling.
 
double mean () override
 Not implemented; use this class only for sampling.
 
double std () override
 Not implemented; use this class only for sampling.
 
- Public Member Functions inherited from IMarginalDistribution
virtual ~IMarginalDistribution ()=default
 
virtual Vector sample (std::size_t n)=0
 
virtual ~IMarginalDistribution ()=default
 Virtual destructor for safe polymorphic deletion.
 

Detailed Description

Discrete marginal sampler using Vose's alias method.

This class implements efficient O(1) sampling from a finite weighted support.

The constructor:

  • checks consistency of values/weights,
  • optionally computes weighted mean and standard deviation,
  • builds alias tables for fast random generation.

If standardize is enabled, samples returned by rvs are transformed as:

\[
  z = \frac{x-\mu}{\sigma}.
\]

Note
Random sampling is implemented. Analytical distribution methods are deliberately unavailable until their discrete semantics are finalized; they throw std::logic_error instead of returning a plausible placeholder value.

Definition at line 63 of file LikelihoodMarginal.h.

Constructor & Destructor Documentation

◆ LikelihoodMarginal()

LikelihoodMarginal::LikelihoodMarginal ( std::vector< double >  values,
std::vector< double >  weights,
unsigned int  seed = std::random_device{}(),
bool  standardize = false 
)

Constructs a discrete likelihood marginal.

Parameters
valuesSupport values.
weightsNon-negative weights associated with support values.
seedSeed for the internal random engine.
standardizeIf true, sampled values are centered and rescaled using the weighted mean and standard deviation.
Exceptions
std::invalid_argumentif:
  • values is empty,
  • values and weights sizes differ,
  • a weight is invalid,
  • the total weight is non-positive.

Definition at line 3 of file LikelihoodMarginal.cpp.

Member Function Documentation

◆ cdf()

double LikelihoodMarginal::cdf ( double  )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 100 of file LikelihoodMarginal.h.

◆ f_df_ddf()

PDFDiff LikelihoodMarginal::f_df_ddf ( double  )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 94 of file LikelihoodMarginal.h.

◆ logpdf()

double LikelihoodMarginal::logpdf ( double  )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 89 of file LikelihoodMarginal.h.

◆ mean()

double LikelihoodMarginal::mean ( )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 110 of file LikelihoodMarginal.h.

◆ ppf()

double LikelihoodMarginal::ppf ( double  )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 105 of file LikelihoodMarginal.h.

◆ rvs()

std::vector< double > LikelihoodMarginal::rvs ( std::size_t  n)
overridevirtual

Draws random samples from the marginal distribution.

Parameters
nNumber of samples to generate.
Returns
std::vector<double> of size n containing iid draws.

Implements IMarginalDistribution.

Definition at line 81 of file LikelihoodMarginal.cpp.

◆ std()

double LikelihoodMarginal::std ( )
inlineoverridevirtual

Not implemented; use this class only for sampling.

Implements IMarginalDistribution.

Definition at line 115 of file LikelihoodMarginal.h.


The documentation for this class was generated from the following files: