mercredi 2 mai 2018

Getting a random list from another list with exact indices

Hellow. I have some trouble with this question:

  1. i have a list, for example a=[1,4,5,7,10]`
  2. i need another list with randomly chosen elements from a (b = np.random.choice(a,3,replace=False)`)

But the length of the b must be the same as len(a). I guess i confuse someone with that text, so here are example :

  1. a = [1,4,5,7,10]
  2. b = [0,4,0,7,10]

so, the elements that wasn't chosen must be zeros. How can i do something like that?




Aucun commentaire:

Enregistrer un commentaire