Esta página aún no se ha traducido para esta versión. Puede ver la versión más reciente de esta página en inglés.

Generación de números aleatorios

Semillas, distribuciones, algoritmos

Utilice las funciones rand, randn y randi para crear secuencias de números pseudoaleatorios y la función randperm para crear un vector de números enteros permutados de manera aleatoria. Use la función rng para controlar la capacidad de repetición de los resultados. Use la clase RandStream cuando necesite controlar de forma más avanzada la generación de números aleatorios.

Funciones

expandir todo

randNúmeros aleatorios distribuidos uniformemente
randnNúmeros aleatorios normalmente distribuidos
randiPseudoaleatorio enteros distribuidos uniformemente
randpermRandom permutation of integers
rngControl random number generator
RandStreamRandom number stream

Temas

Generar números aleatorios

Create Arrays of Random Numbers

Use rand, randi, randn, and randperm to create arrays of random numbers.

Random Numbers Within a Specific Range

This example shows how to create an array of random floating-point numbers that are drawn from a uniform distribution in a specific interval.

Random Integers

This example shows how to create an array of random integer values that are drawn from a discrete uniform distribution on a specific set of numbers.

Random Numbers from Normal Distribution with Specific Mean and Variance

This example shows how to create an array of random floating-point numbers that are drawn from a normal distribution having a specified mean and variance.

Random Numbers Within a Sphere

This example shows how to create random points within the volume of a sphere.

Why Do Random Numbers Repeat After Startup?

Avoid repetition of random number arrays when MATLAB® restarts.

Replace Discouraged Syntaxes of rand and randn

Replace Discouraged Syntaxes of rand and randn.

Controlar la generación de números aleatorios

Controlling Random Number Generation

This example shows how to use the rng function, which provides control over random number generation.

Generate Random Numbers That Are Repeatable

This example shows how to repeat arrays of random numbers by specifying the seed first. Every time you initialize the generator using the same seed, you always get the same result.

Generate Random Numbers That Are Different

This example shows how to avoid repeating the same random number arrays when MATLAB restarts.

Controlar varias secuencias o subsecuencias

Managing the Global Stream

This topic shows how to use the RandStream constructor to control random number generation.

Multiple Streams

This example uses RandStream to create multiple, independent random number streams.

Creating and Controlling a Random Number Stream

This topic uses RandStream to create random number streams and substreams.