boostorg / boostorg/random

uniform_01 generator

Open
#47 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
42
Forks
76
Avg merge
4d 8h
Merged PRs (30d)
5

Description

There's this comment in `uniform_01.hpp`:

> Note: The current implementation is buggy, because it may not fill
> all of the mantissa with random bits. I'm unsure how to fill a
> (to-be-invented) @c boost::bigfloat class with random bits efficiently.

We do have an efficient algorithm ([see section 4 of this preprint](https://arxiv.org/pdf/1810.04744.pdf)) and a [C++ implementation](https://github.com/DiscreteLogarithm/canonical-random-float) capable of generating all representable floating-point numbers in [0,1). It fills the mantissa with a random integer and generates a geometric random number for the exponent. In the double precision case, it is even faster than simply multiplying a 64-bit integer by 2-64 and in the single precision case it's only 25% slower than multiplying a 32-bit integer by 2-32 (when used with the MT19937 URBG).

If you are interested we can help to integrate it into boost.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.