Celeritas  0.5.0-86+4a8eea4
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 = real_type
 

Public Member Functions

CELER_FUNCTION RejectionSampler (real_type f, real_type fmax)
 Construct with acceptance probability and maximum probability.
 
CELER_FUNCTION RejectionSampler (real_type f)
 Construct when the distribution's maximum is normalized.
 
template<class Generator >
CELER_FUNCTION result_type operator() (Generator &rng)
 
template<class Generator >
CELER_FUNCTION auto operator() (Generator &rng) -> result_type
 Sample a random number according to the distribution.
 

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 function g(x) . Given a maximum value M 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)} \]

These invocations generate statistically equivalent results:

This is meant for rejection sampling, e.g., on cross section:

do {
xs = sample_xs(rng);
} while (RejectionSampler{xs, xs_max}(rng));
CELER_FUNCTION RejectionSampler(real_type f, real_type fmax)
Construct with acceptance probability and maximum probability.
Definition: RejectionSampler.hh:86

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