Qu

uniform

Builtin index · Statistics & ML

result = uniform(a, b, [rows], [cols], [seed=])

Input: a, b, rows, cols, seed · Output: result

What it is

Draws from the uniform distribution on [a, b), two numbers a < b, with the same rows/cols/seed= shape as rand.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = uniform(a, b, [rows], [cols], [seed=])
a numbernot documented yet
b numbernot documented yet
rows number, optionalnot documented yet
cols number, optionalnot documented yet
seed number, optionalnot documented yet
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

The rest of the RNG family besides rand/randn themselves (those two stay special-cased in call_named — see its own comment). All share rand/randn's two conventions: distribution parameters come first, size (rows, cols) after, and an explicit seed= gives a fresh reproducible local stream rather than advancing the persistent one.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.