Skip to content

rand

Uniformly distributed random numbers in [0, 1].

r = rand
r = rand(n)
r = rand(m, n)
r = rand(d1, d2, d3, ...)

Returns pseudorandom values drawn from the uniform distribution on [0, 1]. With no arguments, returns a single scalar. With dimensions, returns an array of the requested shape. Uses MathJet’s interpreter-shared PRNG state.

rand % e.g. 0.4321
rand(3) % 3×3 uniform random matrix
rand(1, 100) % row vector of 100 samples
  • randn — Standard-normal random numbers (mean 0, variance 1).
  • randi — Uniformly distributed random integers.
  • rands — Random symmetric matrix.
  • randh — Random Hermitian (complex symmetric) matrix.