1

I want to create a 60x3 matrix of integers. Each integer can be in the range 0-40. Each row vector itself in this matrix must have different elements. The vectors itself can be repeated.

What I want:

np.array([[5,6,7],[3,4,10],[20,45,30],[5,6,7]]) #repititions are ok

What I do not want:

np.array([[5,6,7],[3,4,10],[20,45,30],[5,5,20]])  #the 5 is contained twice in the last vector

Using the numpy function: np.random.choice(40, [60, 3], replace=True) yields to cases which I mentioned as "I do not want". Setting replace=False, does not work due to the lack of combinations.

A very inperfomant way so far (but works as wanted):

for i in range(60):
    rand[i] = np.random.choice(40, [1, 3], replace=False)

Do you have any recommandations (preferred very perfomant ways)?

horsti
  • 113
  • 1
  • 7
  • In particular, [this answer](https://stackoverflow.com/a/47676734/565635) from the duplicate question works for you (after changing the parameters). – orlp Nov 04 '20 at 16:41

0 Answers0