How to generate probability value randomly?

1 vue (au cours des 30 derniers jours)
Mira le
Mira le le 26 Oct 2020
Commenté : Ameer Hamza le 26 Oct 2020
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.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 26 Oct 2020
Try this
X = [1 , 2, 10, 5, 4];
prob = rand(size(X))
  2 commentaires
Mira le
Mira le le 26 Oct 2020
Thank you very much, it works.
Ameer Hamza
Ameer Hamza le 26 Oct 2020
I am glad to be of help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by