This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Pseudorandom and Quasirandom Number Generation

Generate pseudorandom and quasirandom sample data

In certain circumstances, the common methods of random number generation are inadequate to produce the desired samples. Statistics and Machine Learning Toolbox™ offers several alternative methods to generate pseudorandom and quasirandom numbers. Quasirandom numbers, also known as low discrepancy sequences, generate each successive number as far away as possible from existing numbers in the set. This approach avoids clustering and can speed up convergence, but quasirandom numbers are generally too uniform to pass randomness tests. Pseudorandom numbers are less uniform than quasirandom numbers and may be more appropriate for applications that require greater randomness. Use the slice sampler, the Hamiltonian Monte Carlo sampler, or the Metropolis-Hastings Markov chain sampler to generate pseudorandom samples by drawing from a statistical distribution.

If the available parametric probability distributions do not adequately describe your data, you can use a flexible distribution family instead. The Pearson and Johnson flexible distribution families fit a model based on the location, scale, skewness, and kurtosis of the sample data. Once you fit a distribution to your data, you can generate pseudorandom numbers from that distribution.


slicesample Slice sampler
mhsample Metropolis-Hastings sample
hmcSampler Hamiltonian Monte Carlo (HMC) sampler
pearsrnd Pearson system random numbers
johnsrnd Johnson system random numbers


haltonset Halton quasi-random point sets
qrandset Quasi-random point sets
qrandstream Quasi-random number streams
sobolset Sobol quasi-random point sets
HamiltonianSampler Hamiltonian Monte Carlo (HMC) sampler


Representing Sampling Distributions Using Markov Chain Samplers

Markov chain samplers can generate numbers from a sampling distribution that is difficult to represent directly.

Bayesian Linear Regression Using Hamiltonian Monte Carlo

Learn how to use the Hamiltonian Monte Carlo sampler.

Generating Data Using Flexible Families of Distributions

The Pearson and Johnson systems are flexible parametric families of distributions that provide good matches for a wide range of data shapes.

Generating Quasi-Random Numbers

Quasi-random number generators (QRNGs) produce highly uniform samples of the unit hypercube.

Was this topic helpful?