Class HostRandom
Defined in File HostRandom.cuh
Class Documentation
-
class HostRandom
Utility for accessing random generation within host functions This is prefered over using std random, as it uses a common seed with the device random This should only be instantiated by HostAPI
Public Functions
-
template<typename T>
inline T uniform() const Returns a float uniformly distributed between 0.0 and 1.0.
Note
It may return from 0.0 to 1.0, where 0.0 is included and 1.0 is excluded.
Note
Available as float or double
- Template Parameters:
T – return type (must be floating point)
-
template<typename T>
inline T normal() const Returns a normally distributed float with mean 0.0 and standard deviation 1.0.
Note
This result can be scaled and shifted to produce normally distributed values with any mean/stddev.
Note
Available as float or double
- Template Parameters:
T – return type (must be floating point)
-
template<typename T>
inline T logNormal(T mean, T stddev) const Returns a log-normally distributed float based on a normal distribution with the given mean and standard deviation.
Note
Available as float or double
- Template Parameters:
T – return type (must be floating point)
-
template<typename T = unsigned int>
inline unsigned int poisson(double mean = 1.0f) const Returns a poisson distributed unsigned int according to the provided mean (default 1.0).
Note
Available as signed and unsigned: char, short, int, long long (default unsigned int)
- Parameters:
mean – The mean of the distribution
-
template<typename T>
inline T uniform(T min, T max) const Returns an integer uniformly distributed in the inclusive range [min, max] or Returns a floating point value uniformly distributed in the inclusive-exclusive range [min, max)
Note
Available as signed and unsigned: char, short, int, long long
- Template Parameters:
T – return type
-
void setSeed(uint64_t seed)
Change the seed used for random generation
- Parameters:
seed – New random seed
-
uint64_t getSeed() const
Returns the last value used to seed random generation
-
template<>
inline char uniform(const char min, const char max) const Special cases, std::random doesn’t support char, emulate behaviour
-
template<>
inline unsigned char uniform(const unsigned char min, const unsigned char max) const
-
template<>
inline signed char uniform(const signed char min, const signed char max) const
-
template<>
inline float uniform(const float min, const float max) const
-
template<>
inline double uniform(const double min, const double max) const
-
template<typename T>