W3cubDocs

/Octave

26.6 Random Number Generation

Octave can generate random numbers from a large number of distributions. The random number generators are based on the random number generators described in Special Utility Matrices.

The following table summarizes the available random number generators (in alphabetical order).

Distribution Function
Univariate Discrete Distribution discrete_rnd
Empirical Distribution empirical_rnd
Exponential Distribution rande
Gamma Distribution randg
Poisson Distribution randp
Standard Normal Distribution randn
Uniform Distribution rand
Uniform Distribution (integers) randi
discrete_rnd (v, p)
discrete_rnd (v, p, r)
discrete_rnd (v, p, r, c, …)
discrete_rnd (v, p, [sz])

Return a matrix of random samples from the univariate distribution which assumes the values in v with probabilities p.

When called with a single size argument, return a square matrix with the dimension specified. When called with more than one scalar argument the first two arguments are taken as the number of rows and columns and any further arguments specify additional matrix dimensions. The size may also be specified with a vector of dimensions sz.

If no size arguments are given then the result matrix is the common size of v and p.

empirical_rnd (data)
empirical_rnd (data, r)
empirical_rnd (data, r, c, …)
empirical_rnd (data, [sz])

Return a matrix of random samples from the empirical distribution obtained from the univariate sample data.

When called with a single size argument, return a square matrix with the dimension specified. When called with more than one scalar argument the first two arguments are taken as the number of rows and columns and any further arguments specify additional matrix dimensions. The size may also be specified with a vector of dimensions sz.

If no size arguments are given then the result matrix is a random ordering of the sample data.

© 1996–2018 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/interpreter/Random-Number-Generation.html