How to generate probability value randomly?

Hello,
I have a set of discrete value
X=[1 , 2, 10, 5, ...., 4]
I want each value in X contains a probability value between 0 and 1
example:
1: 0.5,
2:0.1,
5:0.9
.....
Thanks.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 26 日

0 投票

Try this
X = [1 , 2, 10, 5, 4];
prob = rand(size(X))

2 件のコメント

Mira le
Mira le 2020 年 10 月 26 日
Thank you very much, it works.
Ameer Hamza
Ameer Hamza 2020 年 10 月 26 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

リリース

R2017a

質問済み:

2020 年 10 月 26 日

コメント済み:

2020 年 10 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by