This link shows how to calculate it using the standard random()
function.
I should note that you will most likely have to execute the ranf()
procedure, which converts the output of random()
from [0,MAX_INT]
to from [0,1]
, but this should not be too complicated.
From a related article:
The polar form of Box-Muller conversion is faster and more reliable. Algorithmic description: float x1, x2, w, y1, y2;
do { x1 = 2.0 * ranf() - 1.0; x2 = 2.0 * ranf() - 1.0; w = x1 * x1 + x2 * x2; } while ( w >= 1.0 ); w = sqrt( (-2.0 * ln( w ) ) / w ); y1 = x1 * w; y2 = x2 * w;
user1118321
source share