# IEEE_UNIFORM_SAMPLE Uniform Sampling of IEEE Values

IEEE_UNIFORM_SAMPLE is a FORTRAN90 program which samples uniformly from the IEEE numbers.

Unlike usual random number generators, which attempt to sample uniformly over a range of real numbers, this library treats the set of IEEE numbers as a discrete set, and randomly samples them. The results are very different from a uniform random number sample.

There are as many IEEE values in the interval (A,B) and the interval (1/B,1/A). This seems fine, and we need this to be so in order to have multiplicative inverses. But it also means that there are as many numbers between 1/1,000,000 and 1 as there are between 1 and 1,000,000. Since the IEEE values are naturally weighted by 2, a better way to think of this is that if there are N values between 1 and 2, then there are also N values between 2 and 4, 4 and 8, 1024 and 2048, one million and 2 million, 2 millionths and 1 millionth, and so on. The density function for the IEEE values looks like a power function 2^(-x).

Let's ignore the "bizarre" IEEE numbers, which include Inf, NaN and the denormalized numbers (very very small values). For 32 bit real numbers, this leaves us with numbers that can be described by a 1 bit sign, an 8 bit exponent biased by 127, and a 23 bit mantissa with an implicit leading 1 and an implicit divisor of 2^23.

Except when a "bizarre" creature would be created, every random sequence of 32 0's and 1's creates a legal IEEE value. So to sample from the IEEE set of values, we can simply create random strings of 0's and 1's.

The current routines are very preliminary, and even so aren't working all that well. However, the idea makes sense, and once some details are worked out, it should be easy to extend this approach to double precision values, or to allow the user to specify a "model" IEEE implementation in which the exponent and mantissa range have been modified.

I am not aware of any serious purpose to which this library could be put, but it does, I think, help in trying to understand that strange structure of the discrete set of numbers that underly almost all of our computations, and that do a reasonably good job of mimicking a continuous range of real values.

### Languages:

IEEE_UNIFORM_SAMPLE is available in a FORTRAN90 version.

### Related Data and Programs:

ASA183, a FORTRAN90 library which implements the Wichman-Hill pseudorandom number generator.

CVT, a FORTRAN90 library which computes elements of a Centroidal Voronoi Tessellation.

FAURE, a FORTRAN90 library which computes elements of a Faure quasirandom sequence.

HALTON, a FORTRAN90 library which computes elements of a Halton Quasi Monte Carlo (QMC) sequence, using a simple interface.

HAMMERSLEY, a FORTRAN90 library which computes elements of a Hammersley Quasi Monte Carlo (QMC) sequence, using a simple interface.

HEX_GRID, a FORTRAN90 library which computes elements of a hexagonal grid dataset.

HEX_GRID_ANGLE, a FORTRAN90 library which computes elements of an angled hexagonal grid dataset.

HISTOGRAM_DATA_2D_SAMPLE, a FORTRAN90 program which demonstrates how to construct a Probability Density Function (PDF) from a frequency table over a 2D domain, and then to use that PDF to create new samples.

IHS, a FORTRAN90 library which computes elements of an improved distributed Latin hypercube dataset.

LATIN_CENTER, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing center points.

LATIN_EDGE, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing edge points.

LATIN_RANDOM, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing points at random.

LCVT, a FORTRAN90 library which computes a latinized Centroidal Voronoi Tessellation.

NIEDERREITER2, a FORTRAN90 library which computes elements of a Niederreiter quasirandom sequence with base 2.

NORMAL, a FORTRAN90 library which computes elements of a sequence of pseudorandom normally distributed values.

SOBOL, a FORTRAN90 library which computes elements of a Sobol quasirandom sequence.

UNIFORM, a FORTRAN90 library which computes elements of a uniform pseudorandom sequence.

VAN_DER_CORPUT, a FORTRAN90 library which computes elements of a van der Corput quasirandom sequence.

### Reference:

1. IEEE Standards Committee 754,
IEEE Standard for Binary Floating Point Arithmetic,
ANSI/IEEE Standard 754-1985,
SIGPLAN Notices,
Volume 22, Number 2, 1987, pages 9-25.

### List of Routines:

• I4_HUGE returns a "huge" I4.
• I4_LOG_2 returns the integer part of the logarithm base 2 of an I4.