0

Imagine that I have written the following code in Matlab.

numItems = 100 ;
Levels = [0.25, 0.5, 0.75, 1.0]
prob = [.25, .25, .25, .25] 
% prob can be any set of probability values.

I want to generate a discrete uniform distribution with values Levels for a vector of numItems elements considering the values of prob.

If I simply explain, I need to do something similar to np.random.choice in Numpy. I tried with unirnd but it is only possible with positive integers by not floating-point numbers.

Can anyone please help me with this? Thanks.

  • do you only use it for this example where all prob values are the same, or is this suppose to be any value as long as they sum up to 1? – bla May 17 '20 at 04:36
  • @bla It can be any set of values which ultimately sum up to 1. – gayan_lanke May 17 '20 at 05:10

0 Answers0