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.

Functions

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

Topics

Generate Random Numbers

Control Random Number Generation

Control Multiple Streams or Substreams