Algorithms for generating random numbers