Celeritas 0.7+972e6cd
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
celeritas::RejectionSampler< RealType > Class Template Reference

Return whether a rejection loop needs to continue trying. More...

#include <RejectionSampler.hh>

Public Types

Type aliases
using real_type = RealType
 
using result_type = bool
 

Public Member Functions

constexpr RejectionSampler (real_type fmax)
 Construct with acceptance probability and maximum probability.
 
constexpr RejectionSampler ()
 Construct when the distribution's maximum is normalized.
 
template<class Generator >
bool operator() (real_type f, Generator &rng) const
 
template<class Generator >
auto operator() (real_type f, Generator &rng) const -> result_type
 Reject with a given probability.
 

Static Public Member Functions

static constexpr real_type tolerance ()
 Allow a priori estimate of fmax to be slightly unconservative.
 

Detailed Description

template<class RealType = ::celeritas::real_type>
class celeritas::RejectionSampler< RealType >

Return whether a rejection loop needs to continue trying.

A common implementation of sampling from a "difficult" (non-analytically invertible) probability distribution function is to bound the difficult distribution f(x) with another easily sampled proposal distribution g(x) . Given a constant M such that \( f(x) < M g(x) \) over the x interval being sampled, it is equivalent to sampling f(x) by instead sampling from g(x) and rejecting with probability

\[ \frac{f(x)}{M g(x)} \]

.

This rejection sampler is constructed with the maximum M and is invoked with the sampled ratio \( f(x)/g(x) \) and an RNG. It allows an underestimate of the constant M by \( 10 \epsilon_\textrm{mach} \) which may result in an imperceptible bias against selecting the peak of the PDF.

These invocations generate statistically equivalent results:

Example
This rejects over a cross section distribution with a known maximum bound.
RejectionSampler reject{xs_max}
do {
xs = sample_xs(rng);
} while (reject(xs, rng));
Return whether a rejection loop needs to continue trying.
Definition RejectionSampler.hh:57

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