mercredi 12 juillet 2017

random matching pairs without test repitition

I have a treatment and control lists, with 10% of the users in control and rest 90% in tests.

control=range(1,11)#create sample control ids
test=range(11,101)#create sample test ids

Now I want to randomly generate pairs of control and test with following rules:

  1. Each control can be mapped to only 2 treatments without repetition. It means our output should look like:

    (1,31), (1,39), (2,26), (2,81).....

So once test 31 is matched to control 1, it cannot be matched to any other control.

  1. Secondly in the above case I have taken only two treatments. But I want it to be passed as a parameter, so that any number of treatments can be matched.



Aucun commentaire:

Enregistrer un commentaire