Forum: CFEngine Help
Subject: Using dist for random selections
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,24500,24500#msg-24500
I working with dist class selection for the purpose of random break tests.
Dist is a bit awkward to use. For instance suppose I want to randomly select a
class from a list of two, where each class has an equal chance? The classic
coin flip. The following will not work.
"flip" dist => { "50", "50" };
The number is appended to "flip" so each list item has be unique. If I change
the numbers the percentages of change.
"flip" dist => { "50", "49" };
This is close but not accurate. The class flip_50 is slightly favoured. It
gets more awkward if more classes are required. Consider choosing randomly
from three.
"flip" dist => { "33", "34" "32" };
Is this as easy as it gets? Have I missed something?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine