mardi 15 mai 2018

Unbiased Random List Generation

Problem Statement

I need to simulate the process of 100 Prisoner Problem, in which each drawer of a cupboard of size 100 contains a unique number from 0 to 99. I initialze the number of drawers as follows:

def arrange_event(n_prisoners=100):
    if (n_prisoners % 2) != 0 or n_prisoners <=0:
        raise ValueError("Number of prisoners must be a postive and even number.")
    drawer = list(range(n_prisoners))
    random.shuffle(drawer)
    return drawer

But I doubt that this implementation (e.g.shuffling from a specific list) will introduce bias to some specific patterns during sampling. A correct implemenation of list initialzation is needed. Any explanation of the bias (if exists) introduced in this implementation will be helpful as well.




Aucun commentaire:

Enregistrer un commentaire