Celeritas 0.7.0-dev.79+develop.b3dc2e108
Loading...
Searching...
No Matches
Public Member Functions | List of all members
celeritas::test::HistogramSampler Class Reference

Sample one or more distributions, returning a histogram. More...

#include <HistogramSampler.hh>

Public Types

Type aliases
using Dbl2 = Histogram::Dbl2
 

Public Member Functions

 HistogramSampler (size_type num_bins, Dbl2 domain, size_type num_samples)
 Construct with number of samples.
 
template<class DistributionT >
SampledHistogram operator() (DistributionT &&sample_from)
 Sample from and accumulate the given distribution.
 
template<class TransformT , class DistributionT >
SampledHistogram operator() (TransformT &&transform, DistributionT &&sample_from)
 Sample from and accumulate the given distribution using a transform.
 

Detailed Description

Sample one or more distributions, returning a histogram.

constexpr size_type num_samples = 1000;
HistogramSampler calc_histogram(8, {-1, 1}, num_samples);
std::vector<SampledHistogram> actual;
for (real_type inc_e : {0.1, 1.0, 1e2, 1e3, 1e6})
{
for (real_type eps : {0.001, 0.01, 0.1})
{
MuAngularDistribution sample_mu{
Energy{inc_e}, muon_mass, Energy{eps * inc_e}};
actual.push_back(calc_histogram(sample_mu));
}
}
SampledHistogram const expected[] = {
{{0, 0, 0, 0, 0.484, 0.604, 0.96, 1.952}, 2},
// ...
};
EXPECT_REF_EQ(expected, actual);
#define EXPECT_REF_EQ(EXPECTED, ACTUAL)
Custom comparison for Celeritas test result types, using ADL.
Definition TestMacros.hh:20
Sample one or more distributions, returning a histogram.
Definition HistogramSampler.hh:62
unsigned int size_type
Standard type for container sizes, optimized for GPU use.
Definition corecel/Types.hh:27
double real_type
Numerical type for real numbers.
Definition corecel/Types.hh:34

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