Skip to main content

random

Standard library Module View source
variable N
N = 624
variable M
M = 397
variable LOG4
LOG4 = _log(4.0)
variable NV_MAGICCONST
NV_MAGICCONST = (4 * _exp(-0.5)).cdiv(_sqrt(2.0))
variable SG_MAGICCONST
SG_MAGICCONST = (1.0 + _log(4.5))
variable TWOPI
TWOPI = (2.0 * _pi)
variable MATRIX_A
MATRIX_A = u32(0x9908b0df)
variable UPPER_MASK
UPPER_MASK = u32(0x80000000)
variable LOWER_MASK
LOWER_MASK = u32(0x7fffffff)
class RandomGenerator
@tuple
class RandomGenerator
Fields 1
data Ptr[u32]
Constructors 1
__new__
__new__()
Properties 2
index
@property
index(self: Self)
state
@property
state(self: Self)
Methods 10
getstate
getstate(self: Self)
setstate
setstate(self: Self, state)
genrand_int32
genrand_int32(self: Self) -> u32
genrand_res53
genrand_res53(self: Self) -> float
random
random(self: Self)
init_u32
init_u32(self: Self, s: u32)
init_array
init_array(self: Self, init_key: Ptr[u32], key_length: int)
init_int
init_int(self: Self, s: int)
random_seed_time_pid
random_seed_time_pid(self: Self)
seed
seed(self: Self, s: int)
seed(self: Self)
class Random
class Random
Fields 2
gen RandomGenerator
gauss_next Optional[float]
Constructors 1
__init__
__init__(self: Self, seed: Optional[int] = None)
Methods 23
seed
seed(self: Self, a: Optional[int])
getstate
getstate(self: Self)
setstate
setstate(self: Self, state)
getrandbits
getrandbits(self: Self, k: int, /) -> int
bit_length
bit_length(self: Self, n: int) -> int
randrange
randrange(self: Self, start: int, stop: int, step: int = 1) -> int
randint
randint(self: Self, a: int, b: int)
random
random(self: Self, /) -> float
choice
choice[T: type](self: Self, sequence: Generator[T]) -> T
@overload
choice[T: type](self: Self, sequence: List[T]) -> T
shuffle
shuffle(self: Self, x)
uniform
uniform(self: Self, a, b) -> float
triangular
triangular(self: Self, low: float, high: float, mode: float) -> float
gammavariate
gammavariate(self: Self, alpha: float, beta: float) -> float
betavariate
betavariate(self: Self, alpha: float, beta: float) -> float
expovariate
expovariate(self: Self, lambd: float) -> float
gauss
gauss(self: Self, mu: float = 0.0, sigma: float = 1.0) -> float
paretovariate
paretovariate(self: Self, alpha: float) -> float
weibullvariate
weibullvariate(self: Self, alpha: float, beta: float) -> float
normalvariate
normalvariate(self: Self, mu: float = 0.0, sigma: float = 1.0) -> float
lognormvariate
lognormvariate(self: Self, mu: float, sigma: float) -> float
vonmisesvariate
vonmisesvariate(self: Self, mu: float, kappa: float) -> float
sample
sample(self: Self, population, k: int)
choices
choices[T: type](self: Self, population, weights: Optional[List[T]], *, cum_weights: Optional[List[T]], k: int)
function seed
seed(a: int)
function getrandbits
getrandbits(k: int, /)
function randrange
randrange(start: int, stop: Optional[int] = None, step: int = 1)
function randint
randint(a: int, b: int)
function choice
choice(s)
function choices
choices[T: type = int](population, weights: Optional[List[T]] = None, *, cum_weights: Optional[List[T]] = None, k: int = 1)
function shuffle
shuffle(s)
function sample
sample(population, k: int)
function random
random()
function uniform
uniform(a, b)
function triangular
triangular(low: float = 0.0, high: float = 1.0, mode: Optional[float] = None)
function betavariate
betavariate(alpha: float, beta: float)
function expovariate
expovariate(lambd: float)
function gammavariate
gammavariate(alpha: float, beta: float)
function gauss
gauss(mu: float, sigma: float)
function lognormvariate
lognormvariate(mu: float, sigma: float)
function normalvariate
normalvariate(mu: float, sigma: float)
function vonmisesvariate
vonmisesvariate(mu: float, kappa: float)
function paretovariate
paretovariate(alpha: float)
function weibullvariate
weibullvariate(alpha: float, beta: float)