How To Generate Non Repeating floating Random Numbers from 1 to 10

조회 수: 2 (최근 30일)
Vikas Rahar
Vikas Rahar 2019년 11월 26일
댓글: Star Strider 2019년 11월 26일
Hi,
Does anybody know how to generate a series of 100 non-repeating random floating numbers between 1 and 10?
Thanks

채택된 답변

Star Strider
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
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
Star Strider
Star Strider 2019년 11월 26일
Noted.
I’d not thought to test this with the ‘Birthday Party’ problem.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrei Bobrov
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));

카테고리

Help CenterFile Exchange에서 Birthdays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by