Contents

gamrnd

Gamma random numbers

Syntax

R = gamrnd(A,B)
R = gamrnd(A,B,m,n,...)
R = gamrnd(A,B,[m,n,...])

Description

R = gamrnd(A,B) generates random numbers from the gamma distribution with shape parameters in A and scale parameters in B. A and B can be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input for A or B is expanded to a constant array with the same dimensions as the other input.

R = gamrnd(A,B,m,n,...) or R = gamrnd(A,B,[m,n,...]) generates an m-by-n-by-... array containing random numbers from the gamma distribution with parameters A and B. A and B can each be scalars or arrays of the same size as R.

Examples

n1 = gamrnd(1:5,6:10)
n1 =
  9.1132  12.8431  24.8025  38.5960 106.4164

n2 = gamrnd(5,10,[1 5])
n2 =
  30.9486  33.5667  33.6837  55.2014  46.8265

n3 = gamrnd(2:6,3,1,5)
n3 =
  12.8715  11.3068  3.0982  15.6012  21.6739
Was this topic helpful?