Table of Contents
Fetching ...

Optimal rolling of fair dice using fair coins

Mark Huber, Danny Vargas

TL;DR

The paper tackles efficient sampling from a finite uniform distribution using fair coin flips within the Knuth–Yao framework. It presents a randomness-recycling implementation that tracks a state $(X,m)$ with $[X|m] \sim \mathrm{d}m$ and doubles $m$ until at least $n$, then either accepts when $X \le n$ or reduces to a smaller subproblem via $(X-n,m-n)$. The authors prove correctness and optimality of the resulting DDG, derive the bound $\mathbb{E}[N_n] \le \lceil \log_2(n) \rceil + 1$, and extend the method to general discrete distributions using a bit-decomposition of probabilities. The approach yields a simple, memory-efficient, near-optimal sampler for fair dice and general discrete distributions, with potential applicability to loaded dice when combined with binary-probability representations.

Abstract

In 1976, Knuth and Yao presented an algorithm for sampling from a finite distribution using flips of a fair coin that on average used the optimal number of flips. Here we show how to easily run their algorithm for the special case of rolling a fair die that uses memory linear in the input. Analysis of this algorithm yields a bound on the average number of coin flips needed that is slightly better than the original Knuth-Yao bound. This can then be extended to discrete distributions in a near optimal number of flips again using memory linear in the input.

Optimal rolling of fair dice using fair coins

TL;DR

The paper tackles efficient sampling from a finite uniform distribution using fair coin flips within the Knuth–Yao framework. It presents a randomness-recycling implementation that tracks a state with and doubles until at least , then either accepts when or reduces to a smaller subproblem via . The authors prove correctness and optimality of the resulting DDG, derive the bound , and extend the method to general discrete distributions using a bit-decomposition of probabilities. The approach yields a simple, memory-efficient, near-optimal sampler for fair dice and general discrete distributions, with potential applicability to loaded dice when combined with binary-probability representations.

Abstract

In 1976, Knuth and Yao presented an algorithm for sampling from a finite distribution using flips of a fair coin that on average used the optimal number of flips. Here we show how to easily run their algorithm for the special case of rolling a fair die that uses memory linear in the input. Analysis of this algorithm yields a bound on the average number of coin flips needed that is slightly better than the original Knuth-Yao bound. This can then be extended to discrete distributions in a near optimal number of flips again using memory linear in the input.
Paper Structure (6 sections, 7 theorems, 14 equations, 2 figures)

This paper contains 6 sections, 7 theorems, 14 equations, 2 figures.

Key Result

Theorem 1

The output of $\textsf{optimal\_uniform}(n)$ is uniform over $\{1, \ldots, n \}$.

Figures (2)

  • Figure 1: From each state, each child is equally likely to be chosen. When a state of the form $(i, 5)$ is reached, output $i$. When state $(1, 1)$ is reached, begin again at the root.
  • Figure 2: Two DDGs for $(3 / 8, 1 / 2, 1 / 8)$. The DDG on the left will always use 3 flips to determine the outcome, while the one on the right uses 1 flip with probability $1 / 2$, 2 flips with probability $1 / 4$, or 3 flips with probability $1 / 4$.

Theorems & Definitions (13)

  • Theorem 1
  • Lemma 1
  • proof
  • proof : Proof of Theorem \ref{['thm:one']}
  • Theorem 2
  • Lemma 2
  • proof
  • Theorem 3
  • proof
  • Theorem 4
  • ...and 3 more