mercredi 15 septembre 2021

sample n random permutations of a list in python

I have a list of values such as:

lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

and I need to reproducibly return n random shuffles of this list.

Ideally, I need a function with seed such that f(lst, samples = 2, seed = 1234) -> return two shuffles of the list lst such as:

[5, 7, 1, 6, 2, 8, 0, 4, 3, 9]
[8, 7, 3, 0, 1, 4, 5, 9, 6, 2]

Repeated execution of this function (with the same seed) would return the same two lists.




Aucun commentaire:

Enregistrer un commentaire