MATLAB Answers

How to generate probability value randomly?

2 views (last 30 days)
Mira le
Mira le on 26 Oct 2020
Commented: Ameer Hamza on 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.

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 26 Oct 2020
Try this
X = [1 , 2, 10, 5, 4];
prob = rand(size(X))

More Answers (0)

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!