At the heart of this algorithm are two techniques described by Knuth (See references). The algorithm used in rand if fairly fast, operating in constant time while the call to init_rand will operate in linear time.