LuaSTG-x Core API
|
Public Member Functions | |
function | _randbelow (local n) |
function | _set_random (local generator, local seeder) |
function | betavariate (local alpha, local beta) |
function | choice (local seq) |
function | expovariate (local lambd) |
function | gammavariate (local alpha, local beta) |
function | gauss (local mu, local sigma) |
function | lognormvariate (local mu, local sigma) |
function | normalvariate (local mu, local sigma) |
function | paretovariate (local alpha) |
function | randint (local a, local b) |
function | random () |
function | randrange (local start, local stop, local step) |
function | sample (local population, local k) |
function | seed (local a) |
function | shuffle (local x, local random) |
function | triangular (local low, local high, local mode) |
function | uniform (local a, local b) |
function | vonmisesvariate (local mu, local kappa) |
function | weibullvariate (local alpha, local beta) |
Return a random int in the range [0, n)
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.
lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, and from negative
infinity to 0 if lambd is negative.
lambd | number |
Gamma distribution. Not the gamma function!
Conditions on the parameters are alpha > 0 and beta > 0.
The probability distribution function is:
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = -----------------------------------—
math.gamma(alpha) * beta ** alpha
alpha | number |
beta | number |
Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function.
mu | number |
sigma | number |
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 |
Return random integer in range [a, b], including both end points.
a | number |
b | number |
function random | ( | ) |
Choose a random item from range(start, stop[, step]).
It does not include the endpoint.
start | number |
stop | number |
step | number |
Chooses k unique random elements from a population sequence or set.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be valid random
samples. This allows raffle winners (the sample) to be partitioned
into grand prize and second place winners (the subslices).
Members of the population need not be hashable or unique. If the
population contains repeats, then each occurrence is a possible
selection in the sample.
population | table |
k | number |
Shuffle list x in place, and return None.
Optional argument random is a 0-argument function returning a
random float in [0.0, 1.0); if it is the default None, the
standard random.random will be used.
Triangular distribution.
Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between.
http://en.wikipedia.org/wiki/Triangular_distribution
low | number |
high | number |
mode | number |
Get a random number in the range [a, b) or [a, b] depending on rounding.
a | number |
b | number |
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 |