MATLAB: Is there any difference between rand(n,1) and unifrnd(0, 1, n, 1)

random number generator

Is there any difference between
rand(n,1)
and
unifrnd(0, 1, n, 1)?

Best Answer

They both generate sample from uniform distribution, unifrnd offers a possibility to enter the parameters while with rand you need to adjust them, example of uniform distribution of interval [5,10] with size of 400 :
h1=unifrnd(5,10,1,400);
h2=5+5*rand(1,400); % same pdf