Exact and Efficient Sampling from Dynamic Discrete Distributions with Finite-Precision Weights

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Hafner, Lilith Orion, Meligrana, Adriano
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866915956686585856
author Hafner, Lilith Orion
Meligrana, Adriano
author_facet Hafner, Lilith Orion
Meligrana, Adriano
contents Sampling from a dynamic discrete distribution means drawing an index with probability proportional to a mutable set of weights. Classical constant-time techniques such as the Alias Method are well suited to static distributions, but become expensive in dynamic settings because updates require rebuilding auxiliary tables. Existing dynamic approaches, including Forest of Trees and BUcket Sampling (BUS), achieve reasonable practical performance but require infinite precision real arithmetic to be correct and produce meaningfully incorrect results when implemented on real hardware. We present EBUS (Exact BUcket Sampling), a dynamic sampler for finite-precision weights that is exact by construction: every returned index has probability exactly proportional to its represented weight. Our guarantees are proved in a word RAM model with bounded exponent range. In that model, our method supports $O(1)$ worst-case expected sampling time, $O(1)$ amortized time to update a single weight, $O(n)$ space, and $O(n)$ construction. We also provide an implementation for IEEE 64-bit floating-point weights and show experimentally that it is competitive with, and often faster than, several implementations of previous inexact methods while avoiding their numerical failure modes.
format Preprint
id arxiv_https___arxiv_org_abs_2506_14062
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Exact and Efficient Sampling from Dynamic Discrete Distributions with Finite-Precision Weights
Hafner, Lilith Orion
Meligrana, Adriano
Data Structures and Algorithms
Probability
Computation
Sampling from a dynamic discrete distribution means drawing an index with probability proportional to a mutable set of weights. Classical constant-time techniques such as the Alias Method are well suited to static distributions, but become expensive in dynamic settings because updates require rebuilding auxiliary tables. Existing dynamic approaches, including Forest of Trees and BUcket Sampling (BUS), achieve reasonable practical performance but require infinite precision real arithmetic to be correct and produce meaningfully incorrect results when implemented on real hardware. We present EBUS (Exact BUcket Sampling), a dynamic sampler for finite-precision weights that is exact by construction: every returned index has probability exactly proportional to its represented weight. Our guarantees are proved in a word RAM model with bounded exponent range. In that model, our method supports $O(1)$ worst-case expected sampling time, $O(1)$ amortized time to update a single weight, $O(n)$ space, and $O(n)$ construction. We also provide an implementation for IEEE 64-bit floating-point weights and show experimentally that it is competitive with, and often faster than, several implementations of previous inexact methods while avoiding their numerical failure modes.
title Exact and Efficient Sampling from Dynamic Discrete Distributions with Finite-Precision Weights
topic Data Structures and Algorithms
Probability
Computation
url https://arxiv.org/abs/2506.14062