Randomized play-the-winner rule (source code)

= Randomized play-the-winner rule
{title2=RPW$(a,b)$}

In a two-treatment urn design, begin with $a$ balls of each type, draw and replace a ball to allocate treatment, then add $b$ balls of the same type after success or of the opposite type after failure. This <response-adaptive randomization> favours treatments with more observed successes. For RPW$(1,1)$, type-0 probability after counts $(s_0,f_0,s_1,f_1)$ is $(1+s_0+f_1)/(2+s_0+f_0+s_1+f_1)$.