Class AgentRandom

Class Documentation

class AgentRandom

Utility for accessing random generation within agent functions This should only be instantiated by FLAMEGPU_API Wraps curand functions to access an internal curand state *

Public Functions

__forceinline__ __device__ AgentRandom(detail::curandState *d_rng)

Constructs an AgentRandom instance

Parameters:

d_rng – ThreadSafe device curand state instance this is a unique instance for the thread among all concurrently executing kernels

template<typename T>
__forceinline__ __device__ 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<typename T>
__forceinline__ __device__ 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<typename T>
__forceinline__ __device__ 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

__forceinline__ __device__ unsigned int poisson(double mean = 1.0f) const

Returns a poisson distributed unsigned int according to the provided mean (default 1.0).

Poisson

Note

This implementation uses CURAND’s “simple Device API” which is considered the least robust but is more efficient when generating Poisson-distributed random numbers for many different lambdas.

Parameters:

mean – The mean of the distribution

template<typename T>
__forceinline__ __device__ 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 exclusive-inclusive range (min, max]

Uniform Range

Note

Available as signed and unsigned: char, short, int, long long, float, double

Template Parameters:

T – return type

template<>
__forceinline__ __device__ float uniform() const

All templates are specialised Uniform floating point

template<>
__forceinline__ __device__ float normal() const

Normal floating point

template<>
__forceinline__ __device__ float logNormal(const float mean, const float stddev) const

Log Normal floating point

template<>
__forceinline__ __device__ double logNormal(const double mean, const double stddev) const
template<>
__forceinline__ __device__ int64_t uniform(const int64_t min, const int64_t max) const
template<>
__forceinline__ __device__ uint64_t uniform(const uint64_t min, const uint64_t max) const
template<>
__forceinline__ __device__ float uniform(const float min, const float max) const
template<>
__forceinline__ __device__ double uniform(const double min, const double max) const