3 ms·
My argument was for the other direction, using [0,1) when you actually want [0,1]. I agree that if 1.0 would cause a problem in your code you should use a rng t
by mark-r 10y ago
My argument was for the other direction, using [0,1) when you actually want [0,1]. I agree that if 1.0 would cause a problem in your code you should use a rng that avoids it. All of the floating point random number generators I'm familiar with deliver [0,1).
- strainer 10y agoInteresting, I assumed java and javascripts behaviour were common. I dont recall seeing this notation before either [0,1) maybe i will now %)
- mark-r 10y agoI usually use C++ or Python, so I had to look up the others. From Java: "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0." From Javascript: "Return a random number between 0 (inclusive) and 1 (exclusive)" So yes, all 4 are consistent in not including 1.0 in the range of random real numbers. I'd call that common. For more on the notation see https://en.wikipedia.org/wiki/Interval_(mathematics)#Including_or_excluding_endpoints https://en.wikipedia.org/wiki/Interval_(mathematics)#Includi...
- strainer 10y agoApologies I wasn't following properly, and thanks for the interval math pointer.