14,443
edits
m (Add variable y which is missing) 

More concretely, the algorithm operates as follows:
# Generate
# Let {{math1=''i'' = ⌊''nx''⌋ + 1}} and {{math1=''y'' = ''nx'' + 1 − ''i''}}. (This makes {{math''i''}} uniformly distributed on {{math{1, 2, …, ''n''} }} and {{math''y''}} uniformly distributed on {{math[0, 1)}}.)
# If {{math''y'' < ''U<sub>i</sub>''}}, return {{mvari}}. This is the biased coin flip.
# Otherwise, return {{mvarK<sub>i</sub>}}.
