given a function that generates a random integer between 1:5 , how can we generate a random integer 1:7
Utilisateur anonyme
run rand(1:5) twice and record the ordered pair . That makes 25 outcomes. Impose an ordering on these 25 pairs. Now, if the outcome belongs in the first 4 pairs, discard them and the procedure starts over. If not, then note that the remaining 21 pairs can be divided into 7 equally probable subsets.