This is part of the code I'm working on: (Using Python)
import random
pairs = [
(0, 1),
(1, 2),
(2, 3),
(3, 0), # I want to treat 0,1,2,3 as some 'coordinate' (or positional infomation)
]
alphas = [(random.choice([1, -1]) * random.uniform(5, 15), pairs[n]) for n in range(4)]
alphas.sort(reverse=True, key=lambda n: abs(n[0]))
A sample output looks like this:
[(13.747649802587832, (2, 3)), (13.668274782626717, (1, 2)), (-9.105374057105703, (0, 1)), (-8.267840318934667, (3, 0))]
Now I'm wondering is there a way I can give each element in 0,1,2,3 a random binary number, so if [0,1,2,3] = [0,1,1,0], then the desired output using the information above looks like:
[(13.747649802587832, (1, 0)), (13.668274782626717, (1, 1)), (-9.105374057105703, (0, 1)), (-8.267840318934667, (0, 0))]
Thanks!!
Aucun commentaire:
Enregistrer un commentaire