Click here to Skip to main content
15,881,248 members
Articles / General Programming / Algorithms

Partially-Sampled Random Numbers for Accurate Sampling of Continuous Distributions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
16 Mar 2022Public Domain103 min read 27.9K   2   9  
Python code for partially-sampled random numbers for accurate arbitrary-precision sampling
This page describes partially-sampled random numbers (incomplete numbers whose contents are determined only when necessary) and how they can be used to generate uniform and non-uniform random numbers to an arbitrary precision and with user-specified error bounds, while avoiding floating-point arithmetic. The page includes a new sampler for beta-distributed random numbers (with both parameters 1 or greater) and algorithms to compare and sample "e-rands", or partially-sampled exponential random numbers. This page contains Python code for beta and e-rand samplers, describes a generalization to sampling continuous distributions supported on the interval [0, 1], shows that the beta and continuous Bernoulli distributions are special cases of this generalization, and shows correctness test results and an application to weighted random sampling of a data stream of unknown size.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions