alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::rand::distribution::NormalReal< T_Result > Struct Template Reference

Used to sample floating-point values from a normal(-/gaussian) distribution. More...

#include <NormalReal.hpp>

Public Types

using result_type = T_Result

Public Member Functions

constexpr NormalReal (T_Result mean=T_Result{0}, T_Result stdDev=T_Result{1})
 Constructs normal(-/gaussian) distribution with given parameters.
template<concepts::UniformStdEngine T_Engine>
constexpr result_type operator() (T_Engine &engine)
 Selects a value from a normal (-/gaussian) distribution for the configured (mean,stdDev) settings.

Detailed Description

template<std::floating_point T_Result>
struct alpaka::rand::distribution::NormalReal< T_Result >

Used to sample floating-point values from a normal(-/gaussian) distribution.

Usage is analogous to std::normal_distribution<T_Result>

See also
https://en.cppreference.com/w/cpp/numeric/random/normal_distribution.html -> Generates N(mean, stddev). Is using the Box-Muller method of generating normally distributed random numbers from a uniform distribution.
Note
: currently supports 32 and 64 bit floating point types.

Definition at line 73 of file NormalReal.hpp.

Member Typedef Documentation

◆ result_type

template<std::floating_point T_Result>
using alpaka::rand::distribution::NormalReal< T_Result >::result_type = T_Result

Definition at line 75 of file NormalReal.hpp.

Constructor & Destructor Documentation

◆ NormalReal()

template<std::floating_point T_Result>
alpaka::rand::distribution::NormalReal< T_Result >::NormalReal ( T_Result mean = T_Result{0},
T_Result stdDev = T_Result{1} )
inlineexplicitconstexpr

Constructs normal(-/gaussian) distribution with given parameters.

Parameters
meanMean of the target normal distribution.
stdDevStandard deviation of the target normal distribution.

The default is N(0,1). The distribution is sampled using the Box-Muller method. This implementation keeps an internal state, therefore each thread/worker must use its own instance to avoid data races when the same object is accessed concurrently by multiple workers.

Usage is otherwise analogous to std::normal_distribution<T_Result>

See also
https://en.cppreference.com/w/cpp/numeric/random/normal_distribution.html

Definition at line 92 of file NormalReal.hpp.

Member Function Documentation

◆ operator()()

template<std::floating_point T_Result>
template<concepts::UniformStdEngine T_Engine>
result_type alpaka::rand::distribution::NormalReal< T_Result >::operator() ( T_Engine & engine)
inlineconstexpr

Selects a value from a normal (-/gaussian) distribution for the configured (mean,stdDev) settings.

Parameters
enginea random engine conforming to the UniformRandomEngine concept (currently accepts stdlib uniform engines and alpaka engines included in the alpaka::rand::engine namespace)
Returns
a floating-point value sampled from the configured distribution.

Definition at line 105 of file NormalReal.hpp.


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