Skip to content

randi

Uniformly distributed pseudo random integer

randi(imax)

  • imax should be a positive integer.
  • It returns a uniformly distributed pseudo random number taken from the set {1,2,...,imax}.

randi(imax,n)

  • imax should be a positive integer.
  • It returns an n-by-n matrix of uniformly distributed pseudo random numbers taken from the set {1,2,...,imax}.
  • n should be a non-negative integer. If n is zero, it returns an empty array.

randi(imax,s1,s2,...,sn)

  • imax should be a positive integer.
  • It returns an array of size [s1, s2, ..., sn]. The array contains uniformly distributed pseudo random numbers taken from the set {1,2,...,imax}.
  • s1, s2, ..., sN should be non-negative integers. If one of s1, s2, ..., sN is zero, it returns an empty array.

randi(imax,sizeVec)

  • imax should be a positive integer.
  • It returns an array of uniformly distributed pseudo random numbers taken from the set {1,2,...,imax}. The array's size is specified by the size vector sizeVec.
  • sizeVec should contain non-negative elements. If an element of sizeVec is zero, it returns an empty array.