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.

 Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 26 Okt. 2020

0 Stimmen

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

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by