Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Drawing Random Floating-point Numbers from an Interval

Published: 11 April 2022 Publication History

Editorial Notes

The authors have requested minor, non-substantive changes to the VoR and, in accordance with ACM policies, a Corrected Version of Record was published on December 11, 2023. For reference purposes, the VoR may still be accessed via the Supplemental Material section on this citation page.

Abstract

Drawing a floating-point number uniformly at random from an interval [a, b) is usually performed by a location-scale transformation of some floating-point number drawn uniformly from [0, 1). Due to the weak properties of floating-point arithmetic, such a transformation cannot ensure respect of the bounds, uniformity or spatial equidistributivity. We investigate and quantify precisely these shortcomings while reviewing the actual implementations of the method in major programming languages and libraries, and we propose a simple algorithm to avoid these shortcomings without compromising performances.

Supplementary Material

3503512-vor (3503512-vor.pdf)
Version of Record for "Drawing Random Floating-point Numbers from an Interval" by Frédéric Goualard, ACM Transactions on Modeling and Computer Simulation, Volume 32, No. 3 (TOMACS 32:3).

References

[1]
Nelson H. F. Beebe. 2017. The Mathematical-Function Computation Handbook: Programming Using the MathCW Portable Software Library. Springer International Publishing.
[2]
T. J. Dekker. 1971. A floating-point technique for extending the available precision. Numer. Math. 18, 3 (June 1971), 224–242.
[3]
Frédéric Goualard. 2020. Generating random floating-point numbers by dividing integers: A case study. In Proceedings of the International Conference on Computational Science. V. Krzhizhanovskaya (Ed.), Lecture Notes in Computer Science, Vol. 12138. Springer, Amsterdam, The Netherlands, 15–28.
[4]
Nicholas J. Higham. 2002. Accuracy and Stability of Numerical Algorithms (2nd ed.). Society for Industrial and Applied Mathematics, Philadelphia.
[5]
Brad Lee Holian, Ora E. Percus, Tony T. Warnock, and Paula A. Whitlock. 1994. Pseudorandom number generator for massively parallel molecular-dynamics simulations. Phys. Rev. E 50, 2 (August 1994), 1607–1615.
[6]
IEEE. 2019. IEEE Standard for Floating-Point Arithmetic. Technical Report IEEE Std 754-2019 (Revision of IEEE 754-2008). The Institute of Electrical and Electronics Engineers, Inc.
[7]
Daniel Lemire. 2019. Fast random integer generation in an interval. ACM Trans. Model. Comput. Simul. 29, 1, Article 3 (January 2019).
[8]
George Marsaglia and Wai Wan Tsang. 2004. The 64-bit universal RNG. Stat. Probab. Lett. 66, 2 (2004), 183–187.
[9]
Makoto Matsumoto and Takuji Nishimura. 1998. Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator. ACM Trans. Model. Comput. Simul. 8, 1 (January 1998), 3–30.
[10]
Jean-Michel Muller (Ed.). 2010. Handbook of Floating-point Arithmetic. Birkhäuser, Boston.
[11]
Pat H. Sterbenz. 1973. Floating-point Computation. Prentice-Hall, Englewood Cliffs, NJ.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Modeling and Computer Simulation
ACM Transactions on Modeling and Computer Simulation  Volume 32, Issue 3
July 2022
119 pages
ISSN:1049-3301
EISSN:1558-1195
DOI:10.1145/3514182
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 11 April 2022
Accepted: 01 December 2021
Revised: 01 November 2021
Received: 01 July 2021
Published in TOMACS Volume 32, Issue 3

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Floating-point number
  2. IEEE 754 standard
  3. random float

Qualifiers

  • Research-article
  • Refereed

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 484
    Total Downloads
  • Downloads (Last 12 months)90
  • Downloads (Last 6 weeks)3
Reflects downloads up to 01 Sep 2024

Other Metrics

Citations

View Options

Get Access

Login options

Full Access

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Full Text

View this article in Full Text.

Full Text

HTML Format

View this article in HTML Format.

HTML Format

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media