dimanche 9 octobre 2022

algorithm for random extraction of elements

I have some issues understanding why the following procedure for performing random sampling from a set of objects work correctly:

suppose I have a population of 100 males and I want to extract 30 of them. One procedure proposed is the following:

assign to the first element of the list a probability of 30/100 and generate a random number n between 0 and 1. If n<30/100, the element gets selected, otherwise it does not.

If it gets selected, then move to the second element and assign it a probability of 29/99,otherwise move to the secodn record without selecting the first one and assign to it a probability of 30/99.

Eventually, proceding in this way we should reach the desired result of 30 random elements extracted from 100, but I do not understand conceptually why this leads to the correct solution.




Aucun commentaire:

Enregistrer un commentaire