I need to fill a numpy array of three elements with random integers such that the sum total of the array is three (e.g. [0,1,2]
).
By my reckoning there are 10 possible arrays:
111, 012, 021, 102, 120, 201, 210, 300, 030, 003
My ideas is to randomly generate an integer between 1 and 10 using randint
, and then use a look-up table to fill the array from the above list of combinations.
Does anyone know of a better approach?