mercredi 27 octobre 2021

how to count a list of numbers which occour in a random list Python

I run 1000 times of random.choice()from a list from 0-11. how to track of the number of random selections necessary before all 12 number have been selected at least once. (Many will be selected more than once.) For instance, suppose the simulation yields the following sequence of random choices for a single trial: 2 5 6 8 2 9 11 10 6 3 1 9 7 10 0 7 0 7 4, where all 12 numbers have been selected at least once. The count for this example trial is 19. Collect the count for each trial of the simulation in a single list (ultimately consisting of 1,000 counts).




Aucun commentaire:

Enregistrer un commentaire