0

Consider the following documentation example extracting 20 draws of a dice

>>> np.random.multinomial(20, [1/6.]*6, size=1)
array([[4, 1, 7, 5, 2, 1]])

The output I want is a 20-dimensional array with the indeces of the sampling outcomes:

[0,0,0,0,1,2,2,2,2,2,2,2,3,3,3,3,3,4,4,5]

but they should not be sorted. I.e. I want the ouptut of the multinomial to "look like" the output of np.random.uniform or np.random.normal, that is, an array of random draws.

andrea m.
  • 668
  • 7
  • 15

1 Answers1

1

you can get the result with random.choice like this. which takes 20 samples of values 0 to 5 with equal probability. you can also pass parameter p which is probability of each element as array to choice function

np.random.choice(6, 20)
Dev Khadka
  • 5,142
  • 4
  • 19
  • 33