Generate a restricted randomization between two groups, with a bias towards maintaining approximately equal allocation
Contributed by:
Nicholas E. Brunk, Wolfram|Alpha Math Team
Examples
Basic Examples (1)
Generate a sequence of 100 options with a bias of (p = 2/3) towards equal allocation:
Scope (3)
Different weighting can be given to the restriction of equal allocation:
Different sequence lengths can be generated:
Users may replace the default symbols for the groups in any way they like:
Properties and Relations (2)
Find the count of all values that follow an "A” when p is near 1/2:
Compare to when p is near 1. This shows a strong bias for alternating:
Neat Examples (4)
Complete randomization is achieved by a (p = 1/2) weighting towards selection of the underrepresented group:
Complete randomization (p = 1/2) is thus equivalent to simple utilization of RandomChoice, albeit with the sequentially biased algorithm being slower:
"RandomChoice Runtime: " 0.1218419`"Efron Runtime: " 10.9277715` The variance in allocation percentage for a given group can be diminished by weighting the randomization scheme (p ≠ 1/2):
Explore the options in variance of allocation percentage as a function of the bias p:
Publisher
Wolfram|Alpha Math Team
Version History
-
2.0.0
– 23 March 2023
-
1.0.0
– 11 October 2022
Related Resources
Author Notes
To view the full source code for EfronBiasedCoin, evaluate the following: