How To Generate Non Repeating floating Random Numbers from 1 to 10
1 次查看(过去 30 天)
显示 更早的评论
Hi,
Does anybody know how to generate a series of 100 non-repeating random floating numbers between 1 and 10?
Thanks
0 个评论
采纳的回答
Star Strider
2019-11-26
One option:
v = rand(1, 100)*9+1;
[L, H] = bounds(v) % Check
producing (in this run):
L =
1.0846
H =
9.9740
6 个评论
Walter Roberson
2019-11-26
With 2^53 possible rand() outputs, an estimation using The Birthday Paradox logic suggests that the probability of a duplicate rises to 1/2 at about 10^8
更多回答(1 个)
Andrei Bobrov
2019-11-26
z = cumsum(rand(100,1));
mn = min(z);
Z = 9/(max(z) - mn)*(z - mn) + 1;
out = Z(randperm(100));
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!