Random Number
Generate pseudorandom and quasi-random numbers
Statistically random numbers exhibit no predictable pattern or regularity. Sequences of statistically random numbers are used to simulate complex mathematical and physical systems.
MATLAB and Simulink provide random number generators to approximate either a normal distribution or a uniform distribution. You can specify the algorithm as well as the starting seeds, which allows you to precisely replicate your results. MATLAB uses the Mersenne twister as its default RNG. However, you can also choose from other generators including a multiplicative lagged Fibonacci generator and a combined multiple recursive generator.
Many types of Monte Carlo simulation require random number sequences that approximate more exotic distributions such as a custom nonparametric distribution in a high-dimensional space. Statistics Toolbox, for use with MATLAB, provides tools for these scenarios:
- Generators for 27 additional univariate distributions including Weibull, gamma, and Poisson, as well as nonparametric distributions
- Copula based techniques for multivariate distributions
- Markov Chain Monte Carlo simulation including slice sampling and the Metropolis Hastings algorithm
Statistics Toolbox also supports quasi-random number generation for space-filling designs.
Examples and How To
- Simulating Dependent Random Variables Using Copulas (Example)
- New Ways with Random Numbers (Blog)
- Random Numbers (Chapter from Numerical Computing with MATLAB by Cleve Moler)
- Generate Random Vectors with a Fixed Sum (File Exchange)
Software Reference
- Generate Normally Distributed Pseudorandom Numbers (Function)
- Controlling Random Number Generation (Documentation)
- Random Number Streams (Documentation)
- Generating Quasi-Random Numbers (Documentation)
- Representing Sampling Distributions Using Markov Chain Samplers (Documentation)
- Randomizing Seeds for Random Number Generators in Blocks (Function)
See also: machine learning, smoothing, data analysis, mathematical modeling
