Overview
Random distribution functions generate samples from standard probability distributions. All functions support deterministic sampling viasetSeed().
Seed Management
setSeed
Set global random seed for deterministic sampling.Random seed value (any finite number)
getSeed
Get current random seed.Current seed value or undefined if not set
clearSeed
Clear the current random seed and revert to cryptographically secure randomness.Continuous Distributions
uniform
Random samples from continuous uniform distribution.Lower boundary (default: 0)
Upper boundary (default: 1)
Output shape (default: [])
Data type:
'float32' or 'float64' (default: 'float32')Device placement
Tensor with values uniformly distributed in [low, high)
normal
Random samples from normal (Gaussian) distribution.Mean of distribution (default: 0)
Standard deviation (default: 1)
Output shape (default: [])
Options (dtype, device)
Tensor with normally distributed values
exponential
Random samples from exponential distribution.Scale parameter (1/lambda, default: 1, must be > 0)
Output shape (default: [])
Options (dtype, device)
Tensor with exponentially distributed values (all positive)
gamma
Random samples from gamma distribution.Shape parameter (k, must be > 0)
Scale parameter (theta, default: 1, must be > 0)
Output shape (default: [])
Options (dtype, device)
Tensor with gamma distributed values (all positive)
beta
Random samples from beta distribution.Alpha parameter (must be > 0)
Beta parameter (must be > 0)
Output shape (default: [])
Options (dtype, device)
Tensor with values in the open interval (0, 1)
Discrete Distributions
binomial
Random samples from binomial distribution.Number of trials (non-negative integer)
Probability of success (in [0, 1])
Output shape (default: [])
Data type:
'int32' or 'int64' (default: 'int32')Device placement
Tensor with number of successes in range [0, n]
poisson
Random samples from Poisson distribution.Expected number of events (rate, must be >= 0)
Output shape (default: [])
Data type:
'int32' or 'int64' (default: 'int32')Device placement
Tensor with Poisson distributed values
Basic Functions
rand
Random values in half-open interval [0, 1).Output shape
Options (dtype, device)
Tensor with values uniformly distributed in [0, 1)
randn
Random samples from standard normal distribution.Output shape
Options (dtype, device)
Tensor with normally distributed values (mean=0, std=1)
randint
Random integers in half-open interval [low, high).Lowest integer (inclusive)
Highest integer (exclusive)
Output shape
Data type:
'int32' or 'int64' (default: 'int32')Device placement
Tensor with integers uniformly distributed in [low, high)