文档ation

rand (RandStream)

Uniformly distributed random numbers

Syntax

r = rand(s,n)
r = rand(s,m,n)
r = rand(s,[m,n])
r = rand(s,m,n,p,...)
r = rand(s,[m,n,p,...])
r = rand(s)
r = rand(s,size(A))
r = rand(..., 'double')
r = rand(..., 'single')

Description

r = rand(s,n)returns ann-by-nmatrix containing pseudorandom values drawn from the standard uniform distribution on the open interval (0,1). The values are drawn from the random streams.

r = rand(s,m,n)orr = rand(s,[m,n])returns anm-by-nmatrix.

r = rand(s,m,n,p,...)orr = rand(s,[m,n,p,...])returns anm-by-n-by-p-by-... array.

r = rand(s)returns a scalar.

r = rand(s,size(A))returns an array the same size asA.

r = rand(..., 'double')orr = rand(..., 'single')returns an array of uniform values of the specified class.

Note

The size inputsm,n,p, ... should be nonnegative integers. Negative integers are treated as 0.

The sequence of numbers produced byrandis determined by the internal state of the random number streams. Resetting that stream to the same fixed state allows computations to be repeated. Setting the stream to different states leads to unique computations, however, it does not improve any statistical properties.

Extended Capabilities