class: mRandomDistribution
generate random numbers with sundry distributions
Description
mRandomDistribution can generate random numbers with a variety of distributions. Functions can be accessed through an instantiated class or statically (eg. mRandomDistribution::triangular(3, 7.5, 6.2) )
Class Methods
float triangular(float lo, float hi, float mid)Generates a random sample N in a triangular distribution in range lo <= N <= hi with a specified mode
lo: lower limit of distribution hi: upper limit of distribution mid: mode of distribution (between lo and hi)
float normal(float mean, float std_dev)Generates a random sample in a normal distribution with specified mean and standard deviation
float log_normal(float mean, float std_dev)Generates a random sample in a log-normal distribution with specified mean and standard deviation.
WARNING: NOT THOROUGHLY TESTED, I THINK THIS FUNCTION CAN RETURN NaN IN SOME CASES
float exponential(float lambda)Generates a random sample in a decreasing exponential distribution with specified lambda
lambda: 1.0 divided by desired mean
float linear(float lo, float hi)Generates a random sample in a decreasing linear distribution with specified min and max
lo: lower limit of output range hi: upper limit of output range
float gamma(float alpha, float beta)Generates a random sample in a gamma distribution with specified alpha and beta
alpha: shape parameter (greater than 0) beta: rate parameter. larger means a wider spread (greater than 0)
float beta(float alpha, float beta)Generates a random sample in a Beta distribution with specified alpha and beta
alpha: shape parameter (greater than 0) beta: rate parameter. larger means a wider spread (greater than 0)
Example