samedi 2 septembre 2023

uniform_real_distribution

I've observed that a sample generated from a std::uniform_real_distribution<float> can be equal to 1 (compiled using Visual Studio 2022).

This is in contrast to the description in standard stating that it should be a uniform draw from [0, 1); hence 1 should be excluded.

Is this cause I'm using float instead of double? Or is this a bug in the Visual Studio 2022 implementation?

And what can I do now? It is important for me that the draw is from [0, 1) and not from [0, 1]. My current solution is to replace the draw u by u - std::floor(u).




Aucun commentaire:

Enregistrer un commentaire