EMPRAND generates random numbers from empirical distribution of data. This is useful when you do not know the distribution type (i.e. normal or uniform), but you have the data and you want to generate random numbers form that data.
The idea is to first construct cumulative distribution function (cdf) from the given data. Then generate uniform random number and interpolate from cdf.
[xr] = emprand(dist) generates single random number from given vector of data values dist.
[xr] = emprand(dist,m) generates m by m matrix of random numbers.
[xr] = emprand(dist,m,n) generates m by n matrix of random numbers.
% Generate 1000 random normal numbers as data for EMPRAND
dist = randn(1000,1);
% Now generate 2000 random numbers from this data
xr = emprand(dist,2000,1);
Thank you it also saved my time :)
Thank you, saved some time!
Hi Durga and everyone,
I have the same problem, but my data lives in an 18-dimensional space. Can I adapt this or would the time/memory explode to do this?
I have the same problem as Israa, matlab can't recognize this function. why??
I tried it many times, but not working I keep getting this error:
" Undefined function 'emprand' for input arguments of type 'double'."
I even checked my path and everything is all right but still not working
It works well but i am getting 'NaN' in my final results. how to fix that? Also how is empcdf different from ecdf? thanks
Nice job. Saved me some work when I realized I had a need for this functionality.
It is good for Bootstrap!
Improvement, bug fixes and simplify the code