I am trying to create a list of vectors with the following conditions:
- each vector has a length of 3
- each value in the vector ranges from 0-2
- there are 14 vectors in the list
- each combination in a vector is unique
The part that I'm struggling with is creating a unique combination of values for each vector.
I wrote a code that works but it is too inefficient and takes too long. So I was wondering if any of you know a code in python that might help. I would really appreciate any advice!
Here is the code I have rn:
empty_array = np.zeros((14,3)) #create an array to hold 14 vectors
x = -1
for i in range(14): #for every neuron:
x = x + 1
random_vector = np.random.randint(0,3,3) #generate a random vector of integers:
#0 = no pdch, 1 = type 1 pdch, 2 = type 2 pdch
while random_vector in empty_array: #ensure vector is unique
random_vector = np.random.randint(0,3,3)
empty_array[x] = random_vector #assign vector to matrix
Aucun commentaire:
Enregistrer un commentaire