Papers › Optimal Approximate Sampling from Discrete Probability Distributions

Optimal Approximate Sampling from Discrete Probability Distributions

13 Jan 2020arXiv:2001.04555links table onlyarchive 2025-07-28

Feras A. Saad, Cameron E. Freer, Martin C. Rinard, Vikash K. Mansinghka

The archive published only this paper's code-link row. Authors, date and abstract are from arXiv's metadata (CC0), read from the Kaggle arXiv metadata snapshot of 2026-09-12 where its title matched the archive's; the title is the archive's.

This paper addresses a fundamental problem in random variate generation: given access to a random source that emits a stream of independent fair bits, what is the most accurate and entropy-efficient algorithm for sampling from a discrete probability distribution (p₁, …, pₙ), where the probabilities of the output distribution (p̂₁, …, p̂ₙ) of the sampling algorithm must be specified using at most k bits of precision? We present a theoretical framework for formulating this problem and provide new techniques for finding sampling algorithms that are optimal both statistically (in the sense of sampling accuracy) and information-theoretically (in the sense of entropy consumption). We leverage these results to build a system that, for a broad family of measures of statistical accuracy, delivers a sampling algorithm whose expected entropy usage is minimal among those that induce the same distribution (i.e., is "entropy-optimal") and whose output distribution (p̂₁, …, p̂ₙ) is a closest approximation to the target distribution (p₁, …, pₙ) among all entropy-optimal sampling algorithms that operate within the specified k-bit precision. This optimal approximate sampler is also a closer approximation than any (possibly entropy-suboptimal) sampler that consumes a bounded amount of entropy with the specified precision, a class which includes floating-point implementations of inversion sampling and related methods found in many software libraries. We evaluate the accuracy, entropy consumption, precision requirements, and wall-clock runtime of our optimal approximate sampling algorithms on a broad set of distributions, demonstrating the ways that they are superior to existing approximate samplers and establishing that they often consume significantly fewer resources than are needed by exact samplers.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2001.04555")

Code

Syntology Ran 0 of 22 code samples harvested from 1 repository linked to this paper; 22 have no recorded run.

By repository: official repository: 22 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

probcomp/optimal-approximate-sampling officialmentioned in paperApache-2.0 report
maciej-bendkowski/boltzmann-brain mentioned on GitHubBSD-3-Clause report
maciej-bendkowski/generic-boltzmann-brain mentioned on GitHubBSD-3-Clause report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested; 0 ran; 0 honoured the contract we drafted; 22 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

22unverified

Licence: 0 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from probcomp/optimal-approximate-sampling. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

construct_sample_ky_encoding probcomp/optimal-approximate-sampling/src/construct.py official repository unverified Apache-2.0 (permissive) · 7f7a7496ddb342a9 · report
construct_sample_ky_matrix probcomp/optimal-approximate-sampling/src/construct.py official repository unverified Apache-2.0 (permissive) · 6f620229d6782cd4 · report
construct_sample_ky_matrix_cached probcomp/optimal-approximate-sampling/src/construct.py official repository unverified Apache-2.0 (permissive) · 8c103a34014ef59a · report
find_optimal_indexes probcomp/optimal-approximate-sampling/src/opt.py official repository unverified Apache-2.0 (permissive) · 30463725333b18bb · report
get_common_denominator probcomp/optimal-approximate-sampling/src/utils.py official repository unverified Apache-2.0 (permissive) · 4cf28f8c3eba0421 · report
get_common_numerators probcomp/optimal-approximate-sampling/src/utils.py official repository unverified Apache-2.0 (permissive) · 388e095eeeca2661 · report
get_delta_error probcomp/optimal-approximate-sampling/src/opt.py official repository unverified Apache-2.0 (permissive) · e716cfd09ac434c7 · report
get_initial_Ms probcomp/optimal-approximate-sampling/src/opt.py official repository unverified Apache-2.0 (permissive) · 4fa6c82bf596ac2b · report
kernel_hellinger probcomp/optimal-approximate-sampling/src/divergences.py official repository unverified Apache-2.0 (permissive) · 8e3254232604c04a · report
kernel_pchi2 probcomp/optimal-approximate-sampling/src/divergences.py official repository unverified Apache-2.0 (permissive) · b542fca2f1e4b985 · report
kernel_tv probcomp/optimal-approximate-sampling/src/divergences.py official repository unverified Apache-2.0 (permissive) · 7f88bdd1e0d18ad7 · report
lcm probcomp/optimal-approximate-sampling/src/utils.py official repository unverified Apache-2.0 (permissive) · 9a61b5ea009c49ab · report
make_ddg_matrix probcomp/optimal-approximate-sampling/src/matrix.py official repository unverified Apache-2.0 (permissive) · 8d3912840cbc2ad0 · report
make_ddg_tree probcomp/optimal-approximate-sampling/src/tree.py official repository unverified Apache-2.0 (permissive) · 9473b3dc91b4a9e3 · report
make_hamming_vector probcomp/optimal-approximate-sampling/src/matrix.py official repository unverified Apache-2.0 (permissive) · 3ff5069ec587d49d · report
make_leaf_table probcomp/optimal-approximate-sampling/src/tree.py official repository unverified Apache-2.0 (permissive) · 599e5c702aea357f · report
make_matrix probcomp/optimal-approximate-sampling/src/matrix.py official repository unverified Apache-2.0 (permissive) · 18fdfd1e058d844d · report
make_tree probcomp/optimal-approximate-sampling/src/tree.py official repository unverified Apache-2.0 (permissive) · 4303f40052d64e52 · report
pack_tree probcomp/optimal-approximate-sampling/src/packing.py official repository unverified Apache-2.0 (permissive) · 97a14f39df6e7aa7 · report
sample_ky_encoding probcomp/optimal-approximate-sampling/src/sample.py official repository unverified Apache-2.0 (permissive) · b8308fdb20d40153 · report
sample_ky_matrix probcomp/optimal-approximate-sampling/src/sample.py official repository unverified Apache-2.0 (permissive) · f19d056c1eb9addc · report
sample_ky_matrix_cached probcomp/optimal-approximate-sampling/src/sample.py official repository unverified Apache-2.0 (permissive) · 2ff3534a77da0bc7 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections