Difference between unifrnd and rand () functions in matlab

I am a little confused about the use rand()

and unifrnd()

in the interval [0,1]. How different? The definitions from this Matlab tutorial are as follows:

rand() - Uniformly distributed pseudorandom numbers 
unifrnd() - Continuous uniform random numbers  

      

+3


source to share


1 answer


I assume you mean unifrnd

(not " unifrand

").

unifrnd

is part of the statistics toolbar, while it rand

is a basic Matlab function.



unifrand

is just a wrapper rand

that allows you to specify additional parameters to define an interval of random values ​​( rand

outputs values ​​in [0,1]). You can do the same with rand

using (a-b)*rand(...)+b

, where a

and b

- the desired interval. Type open unifrnd

in Matlab to see the code unifrnd

.

Another difference is that in recent versions Matlab rand

allows you to specify the data type of the generated output: single

or double

.

+4


source







All Articles