mercredi 28 mars 2018

Generate random int in 3D array

l would like to generate a random 3d array containing random integers (coordinates) in the intervalle [0,100].

so, coordinates=dim(30,10,2)

What l have tried ?

coordinates = [[random.randint(0,100), random.randint(0,100)] for _i in range(30)]

which returns

array([[97, 68],
       [11, 23],
       [47, 99],
       [52, 58],
       [95, 60],
       [89, 29],
       [71, 47],
       [80, 52],
       [ 7, 83],
       [30, 87],
       [53, 96],
       [70, 33],
       [36, 12],
       [15, 52],
       [30, 76],
       [61, 52],
       [87, 99],
       [19, 74],
       [37, 63],
       [40,  2],
       [ 8, 84],
       [70, 32],
       [63,  8],
       [98, 89],
       [27, 12],
       [75, 59],
       [76, 17],
       [27, 12],
       [48, 61],
       [39, 98]])

of shape (30,10)

What l'm supposed to get ?

dim=(30,10,2) rather than (30,10)




Aucun commentaire:

Enregistrer un commentaire