Main Content

Random Number Generation

Seeds, distributions, algorithms

Use the rand, randn, and randi functions to create sequences of pseudorandom numbers, and the randperm function to create a vector of randomly permuted integers. Use the rng function to control the repeatability of your results. Use the RandStream class when you need more advanced control over random number generation.


expand all

randUniformly distributed random numbers
randnNormally distributed random numbers
randiUniformly distributed pseudorandom integers
randpermRandom permutation of integers
rngControl random number generator
RandStreamRandom number stream


Generate Random Numbers

Control Random Number Generation

Control Multiple Streams or Substreams