Optimized random number generator