Drawing random floating-point numbers from an interval - Archive ouverte HAL Access content directly
Journal Articles ACM Transactions on Modeling and Computer Simulation Year : 2022

Drawing random floating-point numbers from an interval

(1)
1

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.
Fichier principal
Vignette du fichier
rand-in-range.pdf (1.09 Mo) Télécharger le fichier
Origin : Files produced by the author(s)

Dates and versions

hal-03282794 , version 1 (09-07-2021)
hal-03282794 , version 2 (03-12-2021)
hal-03282794 , version 3 (12-08-2022)
hal-03282794 , version 4 (07-10-2022)

Identifiers

  • HAL Id : hal-03282794 , version 2

Cite

Frédéric Goualard. Drawing random floating-point numbers from an interval. ACM Transactions on Modeling and Computer Simulation, 2022, 32 (3). ⟨hal-03282794v2⟩
526 View
843 Download

Share

Gmail Facebook Twitter LinkedIn More