Graph of Pr(rand.Float64() < x) for various implementations

Russ Cox, January 2016

 

The blue line is ideal, Pr(rand.Float64() < x) = x. The red line is the analytically exact probability.

Make your browser wide enough to see four graphs across. Then the four columns show behavior very close to zero (scale 1/2^63), somewhat zoomed out from zero (scale 1/2^53), centered on 0.5 (scale 1/2^53), and close to one (scale 1/2^53).

Computed with rsc.io/tmp/randdist.

Go 1.1 behavior

Go 1.5 behavior

Go 1.6 behavior