mercredi 25 novembre 2020

Randomly selecting a value (from a subset of values) at even distribution within a group in excel

I have an excel document with the the following values (only those that are relevant here are provided).

For the value column, I want to select from the values 200, 400, 600, and apply them randomly to each row. Beyond this, I need to have an even distribution within each ID (therefore each ID would have 200 twice, 400 twice, 600 twice).

currently, I have been using this excel formula =CHOOSE(RANDBETWEEN(1,3),200,400,600) in the value column, which randomly selects from the three values, but obviously does not provide an even distribution within each ID group (although it may in certain instances by chance).

ID  value
1   x
1   x
1   x
1   x
1   x
1   x
1   x
2   x
2   x
2   x
2   x
2   x
2   x
3   x
3   x
3   x
3   x
3   x
3   x

Does anyone have a solution for this, either in Excel or Python?




Aucun commentaire:

Enregistrer un commentaire