exponential
Builtin index · Statistics & ML
result = exponential(rate, [rows], [cols], [seed=])
Input: rate, rows, cols, seed · Output: result
What it is
Exponential draws. rate (a positive number) is the rate, not the scale: the mean is 1/rate, and NumPy instead takes scale = 1/rate directly, so a value copied from NumPy needs inverting; rows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix; seed= (number, optional) makes the draw repeatable.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = exponential(rate, [rows], [cols], [seed=]) | rate numberrate (a positive number) is the rate, not the scale: the mean is 1/rate, and NumPy instead takes scale = 1/rate directly, so a value copied from NumPy needs inverting.rows number, vector, or matrix, optionalrows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix.cols number, vector, or matrix, optionalrows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix.seed number, optionalseed= (number, optional) makes the draw repeatable. | result number, vector, or matrix | Returns a number, vector, or (rows, cols) matrix. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
u = uniform(10, 20, 5) # 5 draws, continuous uniform on [10, 20)
g = normal(5, 2, 1000, seed=1) # 1000 draws, mean 5, std 2 — randn is mu=0/sigma=1
d = randi(1, 6, 10) # 10 dice rolls, inclusive both ends
k = poisson(4, 500) # 500 draws from Poisson(lambda=4)
t = exponential(2, 500) # 500 draws, rate=2 (mean = 1/rate = 0.5)
b = binomial(20, 0.3, 500) # 500 draws, 20 trials at p=0.3 each
from numerics-dsp
How it works
exponential(rate, ...) — rate parameterization (mean = 1/rate); see Rng::exponential's doc comment.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.