Contents Previous Next Subchapters Current Chapters-> prctile ftail tpdf ttail ittail cnormal inormal rand snormal seed colmad colmse colrange colmode kurtosis skewness randperm ranseed unifm0v1 unirnd normrnd exprnd gamrnd cauchyrnd gumbelrnd laplacernd lognrnd wblrnd binornd poissrnd exppdf expcdf normpdf unifpdf unifcdf wblpdf wblcdf colcor colcov colmean colstd colmax rowmax colsum rowsum colnorm rownorm median colmedian colmead colvar corr conv conv2 sum cumsum prod cumprod Parent Chapters-> Omatrix6 statistics rand Search Tools-> contents reference index search

Generating Uniformly Distributed Pseudo Random Numbers
 Syntax `rand(`rows`)` `rand(`rows`, `cols`)` See Also unirnd , normrnd , randperm

Description
Returns a real matrix containing random elements that are uniformly distributed between 0 and 1, where rows is the number of rows and cols is the number of columns. The arguments rows and cols are integer, real, double-precision or complex scalars. If an argument is complex, only its real part is used. If the argument cols is not present, a square matrix is returned.

Example ```      clear      rand(3, 1) ``` results in ```      {      4.65661e-010      0.527357      0.384887      } ``` The `rand` function returns values from a pseudo-random sequence. It always starts at the same point at the beginning of an O-Matrix session and after a `clear`. If you continue the previous example by entering ```      clear      rand(3, 1) ``` O-Matrix will respond ```      {      4.65661e-010      0.527357      0.384887      } ``` which are the same as the numbers output above. If, however, you continue the previous example (without clearing) by entering ```      rand(3, 1) ``` O-Matrix will respond ```      {      0.134948      0.223919      0.643237      } ``` which is a different set of numbers.

Reference
The arguments must be scalars. If they are logical, real, double-precision or complex, the corresponding integer values are used.