octave: Random Number Generation

 
 26.7 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 SeeSpecial Utility Matrices.
 
    The following table summarizes the available random number generators
 (in alphabetical order).
 
 Distribution                  Function
 -----------------------------------------------------
 Beta Distribution             ‘betarnd’
 Binomial Distribution         ‘binornd’
 Cauchy Distribution           ‘cauchy_rnd’
 Chi-Square Distribution       ‘chi2rnd’
 Univariate Discrete           ‘discrete_rnd’
 Distribution
 Empirical Distribution        ‘empirical_rnd’
 Exponential Distribution      ‘exprnd’
 F Distribution                ‘frnd’
 Gamma Distribution            ‘gamrnd’
 Geometric Distribution        ‘geornd’
 Hypergeometric Distribution   ‘hygernd’
 Laplace Distribution          ‘laplace_rnd’
 Logistic Distribution         ‘logistic_rnd’
 Log-Normal Distribution       ‘lognrnd’
 Pascal Distribution           ‘nbinrnd’
 Univariate Normal             ‘normrnd’
 Distribution
 Poisson Distribution          ‘poissrnd’
 Standard Normal               ‘stdnormal_rnd’
 Distribution
 t (Student) Distribution      ‘trnd’
 Univariate Discrete           ‘unidrnd’
 Distribution
 Uniform Distribution          ‘unifrnd’
 Weibull Distribution          ‘wblrnd’
 Wiener Process                ‘wienrnd’
 
  -- : betarnd (A, B)
  -- : betarnd (A, B, R)
  -- : betarnd (A, B, R, C, ...)
  -- : betarnd (A, B, [SZ])
      Return a matrix of random samples from the Beta distribution with
      parameters A and B.
 
      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 A and B.
 
  -- : binornd (N, P)
  -- : binornd (N, P, R)
  -- : binornd (N, P, R, C, ...)
  -- : binornd (N, P, [SZ])
      Return a matrix of random samples from the binomial distribution
      with parameters N and P, where N is the number of trials and P is
      the probability of success.
 
      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 N and P.
 
  -- : cauchy_rnd (LOCATION, SCALE)
  -- : cauchy_rnd (LOCATION, SCALE, R)
  -- : cauchy_rnd (LOCATION, SCALE, R, C, ...)
  -- : cauchy_rnd (LOCATION, SCALE, [SZ])
      Return a matrix of random samples from the Cauchy distribution with
      parameters LOCATION and SCALE.
 
      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 LOCATION and SCALE.
 
  -- : chi2rnd (N)
  -- : chi2rnd (N, R)
  -- : chi2rnd (N, R, C, ...)
  -- : chi2rnd (N, [SZ])
      Return a matrix of random samples from the chi-square distribution
      with N degrees of freedom.
 
      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 size
      of N.
 
  -- : 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.
 
  -- : exprnd (LAMBDA)
  -- : exprnd (LAMBDA, R)
  -- : exprnd (LAMBDA, R, C, ...)
  -- : exprnd (LAMBDA, [SZ])
      Return a matrix of random samples from the exponential distribution
      with mean LAMBDA.
 
      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 size
      of LAMBDA.
 
  -- : frnd (M, N)
  -- : frnd (M, N, R)
  -- : frnd (M, N, R, C, ...)
  -- : frnd (M, N, [SZ])
      Return a matrix of random samples from the F distribution with M
      and N degrees of freedom.
 
      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 M and N.
 
  -- : gamrnd (A, B)
  -- : gamrnd (A, B, R)
  -- : gamrnd (A, B, R, C, ...)
  -- : gamrnd (A, B, [SZ])
      Return a matrix of random samples from the Gamma distribution with
      shape parameter A and scale B.
 
      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 A and B.
 
  -- : geornd (P)
  -- : geornd (P, R)
  -- : geornd (P, R, C, ...)
  -- : geornd (P, [SZ])
      Return a matrix of random samples from the geometric distribution
      with parameter 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 size
      of P.
 
      The geometric distribution models the number of failures (X-1) of a
      Bernoulli trial with probability P before the first success (X).
 
  -- : hygernd (T, M, N)
  -- : hygernd (T, M, N, R)
  -- : hygernd (T, M, N, R, C, ...)
  -- : hygernd (T, M, N, [SZ])
      Return a matrix of random samples from the hypergeometric
      distribution with parameters T, M, and N.
 
      The parameters T, M, and N must be positive integers with M and N
      not greater than T.
 
      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 T, M, and N.
 
  -- : laplace_rnd (R)
  -- : laplace_rnd (R, C, ...)
  -- : laplace_rnd ([SZ])
      Return a matrix of random samples from the Laplace distribution.
 
      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.
 
  -- : logistic_rnd (R)
  -- : logistic_rnd (R, C, ...)
  -- : logistic_rnd ([SZ])
      Return a matrix of random samples from the logistic distribution.
 
      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.
 
  -- : lognrnd (MU, SIGMA)
  -- : lognrnd (MU, SIGMA, R)
  -- : lognrnd (MU, SIGMA, R, C, ...)
  -- : lognrnd (MU, SIGMA, [SZ])
      Return a matrix of random samples from the lognormal distribution
      with parameters MU and SIGMA.
 
      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 MU and SIGMA.
 
  -- : nbinrnd (N, P)
  -- : nbinrnd (N, P, R)
  -- : nbinrnd (N, P, R, C, ...)
  -- : nbinrnd (N, P, [SZ])
      Return a matrix of random samples from the negative binomial
      distribution with parameters N and 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 N and P.
 
  -- : normrnd (MU, SIGMA)
  -- : normrnd (MU, SIGMA, R)
  -- : normrnd (MU, SIGMA, R, C, ...)
  -- : normrnd (MU, SIGMA, [SZ])
      Return a matrix of random samples from the normal distribution with
      parameters mean MU and standard deviation SIGMA.
 
      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 MU and SIGMA.
 
  -- : poissrnd (LAMBDA)
  -- : poissrnd (LAMBDA, R)
  -- : poissrnd (LAMBDA, R, C, ...)
  -- : poissrnd (LAMBDA, [SZ])
      Return a matrix of random samples from the Poisson distribution
      with parameter LAMBDA.
 
      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 size
      of LAMBDA.
 
  -- : stdnormal_rnd (R)
  -- : stdnormal_rnd (R, C, ...)
  -- : stdnormal_rnd ([SZ])
      Return a matrix of random samples from the standard normal
      distribution (mean = 0, standard deviation = 1).
 
      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.
 
  -- : trnd (N)
  -- : trnd (N, R)
  -- : trnd (N, R, C, ...)
  -- : trnd (N, [SZ])
      Return a matrix of random samples from the t (Student) distribution
      with N degrees of freedom.
 
      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 size
      of N.
 
  -- : unidrnd (N)
  -- : unidrnd (N, R)
  -- : unidrnd (N, R, C, ...)
  -- : unidrnd (N, [SZ])
      Return a matrix of random samples from the discrete uniform
      distribution which assumes the integer values 1–N with equal
      probability.
 
      N may be a scalar or a multi-dimensional array.
 
      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 size
      of N.
 
  -- : unifrnd (A, B)
  -- : unifrnd (A, B, R)
  -- : unifrnd (A, B, R, C, ...)
  -- : unifrnd (A, B, [SZ])
      Return a matrix of random samples from the uniform distribution on
      [A, B].
 
      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 A and B.
 
  -- : wblrnd (SCALE, SHAPE)
  -- : wblrnd (SCALE, SHAPE, R)
  -- : wblrnd (SCALE, SHAPE, R, C, ...)
  -- : wblrnd (SCALE, SHAPE, [SZ])
      Return a matrix of random samples from the Weibull distribution
      with parameters SCALE and SHAPE.
 
      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 SCALE and SHAPE.
 
  -- : wienrnd (T, D, N)
      Return a simulated realization of the D-dimensional Wiener Process
      on the interval [0, T].
 
      If D is omitted, D = 1 is used.  The first column of the return
      matrix contains time, the remaining columns contain the Wiener
      process.
 
      The optional parameter N defines the number of summands used for
      simulating the process over an interval of length 1.  If N is
      omitted, N = 1000 is used.