LuaSTG-x Core API
math::Random Class Reference

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)
 

Member Function Documentation

◆ _randbelow()

function _randbelow ( local  n)

Return a random int in the range [0, n)

Parameters
nnumber
Returns
number

◆ _set_random()

function _set_random ( local  generator,
local  seeder 
)

◆ betavariate()

function betavariate ( local  alpha,
local  beta 
)

Beta distribution.

Conditions on the parameters are alpha > 0 and beta > 0.

Returned values range between 0 and 1.

Parameters
alphanumber
betanumber
Returns
number

◆ choice()

function choice ( local  seq)

Choose a random element from a non-empty sequence.

◆ expovariate()

function expovariate ( local  lambd)

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.

Parameters
lambdnumber
Returns
number

◆ gammavariate()

function gammavariate ( local  alpha,
local  beta 
)

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
Parameters
alphanumber
betanumber
Returns
number

◆ gauss()

function gauss ( local  mu,
local  sigma 
)

Gaussian distribution.

mu is the mean, and sigma is the standard deviation. This is

slightly faster than the normalvariate() function.

Parameters
munumber
sigmanumber
Returns
number

◆ lognormvariate()

function lognormvariate ( local  mu,
local  sigma 
)

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.

Parameters
munumber
sigmanumber
Returns
number

◆ normalvariate()

function normalvariate ( local  mu,
local  sigma 
)

Normal distribution.

mu is the mean, and sigma is the standard deviation.

Parameters
munumber
sigmanumber
Returns
number

◆ paretovariate()

function paretovariate ( local  alpha)

Pareto distribution. alpha is the shape parameter.

Parameters
alphanumber
Returns
number

◆ randint()

function randint ( local  a,
local  b 
)

Return random integer in range [a, b], including both end points.

Parameters
anumber
bnumber
Returns
number

◆ random()

function random ( )

◆ randrange()

function randrange ( local  start,
local  stop,
local  step 
)

Choose a random item from range(start, stop[, step]).

It does not include the endpoint.

Parameters
startnumber
stopnumber
stepnumber
Returns
number

◆ sample()

function sample ( local  population,
local  k 
)

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.

Parameters
populationtable
knumber
Returns
table

◆ seed()

function seed ( local  a)

◆ shuffle()

function shuffle ( local  x,
local  random 
)

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()

function triangular ( local  low,
local  high,
local  mode 
)

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

Parameters
lownumber
highnumber
modenumber
Returns
number

◆ uniform()

function uniform ( local  a,
local  b 
)

Get a random number in the range [a, b) or [a, b] depending on rounding.

Parameters
anumber
bnumber
Returns
number

◆ vonmisesvariate()

function vonmisesvariate ( local  mu,
local  kappa 
)

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.

Parameters
munumber
kappanumber
Returns
number

◆ weibullvariate()

function weibullvariate ( local  alpha,
local  beta 
)

Weibull distribution.

alpha is the scale parameter and beta is the shape parameter.

Parameters
alphanumber
betanumber
Returns
number

The documentation for this class was generated from the following file: