This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Random Number Generation

Seeds, distributions, algorithms

Use the rand, randn, and randi functions to create sequences pseudorandom numbers. 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.


rand Uniformly distributed random numbers
randn Normally distributed random numbers
randi Uniformly distributed pseudorandom integers
randperm Random permutation
rng Control random number generation


RandStream Random number stream
Was this topic helpful?