Selecting unique random numbers between 0 to 1 from a vector.

4 ビュー (過去 30 日間)
Rohit Mangalekar
Rohit Mangalekar 2021 年 8 月 30 日
コメント済み: Rohit Mangalekar 2021 年 9 月 6 日
Hello,
I am trying to generate the unique random numbers between 0 to 1 from a obtained vector. I am using "randsample" function to generated the required number of random numbers from the vector 'y'. The thing is this vector 'y' is a cumulative distribution function (CDF) obtained from the manual sum of different probability distribution functions (PDF's). And it contains the large number of 0's and 0.75's.. and these are the two numbers which repeat themselves when I try to generate the random numbers using the "randsample". I am running this program for multiple (thousands) number of times. But at least in a single go, I need unique numbers.
can you suggest the way to generate the unique random numbers in this matter.
pos=randsample(y,4);
  5 件のコメント
Jan
Jan 2021 年 8 月 31 日
I do not understand, what the problem is. Maybe you mean:
index = randperm(1:numel(y), 4);
pickedX = x(index);
pickedY = y(index);
Rohit Mangalekar
Rohit Mangalekar 2021 年 9 月 6 日
Thank you very much @Jan. The command unique helped.

サインインしてコメントする。

回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by