use random() instead of drand48_r

drand48_r() cannot be used in OS X, and it also uses linear congruential generators like rand().
random(), not rand(), can be used in most UNIX systems (including OS X), and it generates better random numbers.