Static methods

staticbetavariate(alpha:Float, beta:Float):Float

Beta distribution. Conditions on the parameters are alpha > 0 and beta > 0. Returned values range between 0 and 1.

staticexpovariate(lambd:Float):Float

Exponential distribution. lambd is 1.0 divided by the desired mean. It should be nonzero. Returned values range from 0 to positive infinity if lambd is positive, and from negative infinity to 0 if lambd is negative.

staticgammavariate(alpha:Float, beta:Float):Float

Gamma distribution. (Not the gamma function!) Conditions on the parameters are alpha > 0 and beta > 0.

staticgauss(mu:Float, sigma:Float):Float

Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate function defined below.

staticgetrandbits(k:Int):Int

Returns a Python integer with k random bits. This method is supplied with the MersenneTwister generator and some other generators may also provide it as an optional part of the API. When available, getrandbits() enables randrange() to handle arbitrarily large ranges.

staticgetstate():RandomState

Return an object capturing the current internal state of the generator. This object can be passed to setstate() to restore the state.

staticlognormvariate(mu:Float, sigma:Float):Float

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.

staticnormalvariate(mu:Float, sigma:Float):Float

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

staticparetovariate(alpha:Float):Float

Pareto distribution. alpha is the shape parameter.

staticrandint(a:Int, b:Int):Int

Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).

staticrandom():Float

Return the next random floating point number in the range [0.0, 1.0).

staticrandrange(start:Int, stop:Int, ?step:Int):Int

staticrandrange(stop:Int):Int

Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object.

staticseed(?a:Int, ?version:Int):Float

Initialize the random number generator.

If a is omitted or null, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).

If a is an int, it is used directly.

With version 2 (the default), a str, bytes, or bytearray object gets converted to an int and all of its bits are used. With version 1, the hash() of a is used instead.

staticsetstate(state:RandomState):Void

state should have been obtained from a previous call to getstate(), and setstate() restores the internal state of the generator to what it was at the time getstate() was called.

statictriangular(?low:Float, ?high:Float, ?mode:Float):Float

Return a random floating point number N such that low <= N <= high and with the specified mode between those bounds. The low and high bounds default to zero and one. The mode argument defaults to the midpoint between the bounds, giving a symmetric distribution.

staticuniform(a:Float, b:Float):Float

Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.

staticvonmisesvariate(mu:Float, kappa:Float):Float

mu is the mean angle, expressed in radians between 0 and 2pi, 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 2pi.

staticweibullvariate(alpha:Float, beta:Float):Float

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