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.

 采纳的回答

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

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

产品

版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by