0

I need to generate 5 integer number which must be from a given set of numbers {1,2,4,8,16}.

I need different values to have different probabilities of generating eg.

0.10 chance of 1
0.15 chance of 2
0.30 chance of 4 
0.25 chance of 8
0.20 chance of 16

How can I do this in Matlab?

1 Answers1

0

You can simply draw a random number between 0 and 1. Then assign each interval one of your numberset. E.g.: random number is 0.12 -> your number will be 2. The first 0.0 to 0.1 will be therefor 1, 0.1 to 0.15 will be 2 and so on...