MATLAB: How to generate probability value randomly

MATLABprobability

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.

Best Answer

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