Celeritas 0.7+ef734374e
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
celeritas::TruncatedDistribution< Distribution > Class Template Reference

Sample from a truncated distribution. More...

#include <TruncatedDistribution.hh>

Public Types

Type aliases
using result_type = typename Distribution::result_type
 
using RecordT = TruncatedDistributionRecord< typename Distribution::RecordT >
 

Public Member Functions

template<class T , class U , class... Args>
 TruncatedDistribution (T lower, U upper, Args &&... args)
 Construct with distribution and truncation bounds.
 
 TruncatedDistribution (RecordT const &record)
 Construct from a device-friendly variant record.
 
template<class Generator >
result_type operator() (Generator &rng)
 
template<class Generator >
auto operator() (Generator &rng) -> result_type
 Sample a random number according to the truncated distribution.
 

Static Public Attributes

static constexpr int max_debug_samples = 32
 Assert fewer than this number of samples is tried when CELERITAS_DEBUG.
 

Detailed Description

template<class Distribution>
class celeritas::TruncatedDistribution< Distribution >

Sample from a truncated distribution.

Sample from an arbitrary distribution truncated to a finite interval. Values are drawn from the underlying distribution using rejection sampling until they fall within the truncation bounds.

Warning
Because of the rejection sampling, it is possible to create a distribution that never (or almost never) accepts a value from the underlying distribution. A loop checker is active in debug mode that prevents more than 32 failed samples. Since GPU performance is so sensitive to rejection failures, consider transforming the underlying distribution if this limit is hit. When using this distribution for physics distributions, it is strongly recommended to use test::HistogramSampler to verify the number of samples being taken.

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