Support custom random number generator in random() and shuffle()

I added support for specifying a custom random generator function to random() and shuffle(). This is useful if you want to make functions that use these functions yield predictable results (by passing in a stable/predictable generator), without influencing other invocations of Math.random, and vice versa, without having other invocations of Math.random influence their result.