C++ Logo

STD-PROPOSALS

Advanced search

Subject: [std-proposals] Distributed random number ordering
From: RICHINGS James (james.richings_at_[hidden])
Date: 2021-05-10 06:13:09


Dear Std-Proposals,

When developing programs for scientific applications the numerical reproducibility of code is of paramount importance if reliable results are to be obtained.

One of the key sources of error is in the sequence in which distributions of random numbers are generated.

By way of example, currently the standard does not require that a given implementation reproduce the same sequence of normally distributed random numbers as it leaves the implementer freedom to choose the algorithm by which to implement the normal distribution. However, this leave the order in which normally distributed random numbers are generated out of the control of the user. This is particularly troubling when currently gcc and llvm have both used the polar method to implement normally distributed random numbers but have decided on different orderings to output the distributed random numbers. This results in a permutation of the even and odd values in a list of normally distributed numbers (1,3,9,4 -> 3,1,4,9). This is not a bug in either implementation as both sequences are valid random numbers, but we cannot control the ordering with the current interface.

This is an issue as this makes it difficult to verify our code against multiple implementations of the standard which we find important when running across multiple machines with different HPC architectures.

Ideally the standard should specify that the order random numbers are returned by a distribution is controllable via a parameter so that the sequence is not dependent on the implementation and that multiple algorithms (if implemented) should be selectable by the user making it possible to always fix the order to a desired convention. This would allow the existing default behaviour to persist but additional control to be added.

Any thoughts on this issue are welcome.

Regards,

James Richings

Research Software Engineer
James Clerk Maxwell Building
University of Edinburgh
Edinburgh
EH9 3FD

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th' ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.



STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups