LuaSTG-x Core API
|
Return a random int in the range [0, n).
Return 0 if n is 0.
n | number |
Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
alpha | number |
beta | number |
Exponential distribution.
lambda is 1.0 divided by the desired mean. It should be
nonzero. Returned values range from 0 to
positive infinity if lambda is positive, and from negative
infinity to 0 if lambda is negative.
lambda | number |
Gamma distribution. (Not the gamma function)
Conditions on the parameters are alpha > 0 and beta > 0.
alpha | number |
beta | number |
Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normal() function.
mu | number |
sigma | number |
function getSeed | ( | ) |
Log normal distribution.
If you take the natural logarithm of this distribution, you'll get a
normal distribution with mean mu and standard deviation sigma.
mu can have any value, and sigma must be greater than zero.
mu | number |
sigma | number |
Normal distribution.
mu is the mean, and sigma is the standard deviation.
mu | number |
sigma | number |
Pareto distribution.
alpha is the shape parameter.
alpha | number |
get random float in range [a, b]
a | number |
b | number |
get random int32 in range [a, b]
a | number |
b | number |
function randSign | ( | ) |
get random 1 or -1
Choose a random item from range(start, stop[, step]).
start | number |
stop | number |
step | number |
Chooses k unique random elements from an array.
Returns a new array.
array | table |
k | number |
Chooses k unique random numbers from a range.
Returns an array.
start | number |
stop | number |
step | number |
k | number |
Chooses k unique random elements from an array by given weight.
Reference: https://www.sciencedirect.com/science/article/abs/pii/S002001900500298X
Returns an array.
array | table |
weight | table |
k | number |
seed | number |
function Sign | ( | ) |
随机生成1或-1
low | number |
high | number |
mode | number |
Uniform distribution.
Get a random number in the range [a, b].
a | number |
b | number |
von Mises distribution (Circular data distribution).
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi.
mu | number |
kappa | number |
Weibull distribution.
alpha is the scale parameter and beta is the shape parameter.
alpha | number |
beta | number |