Added random number generator.

Stolen from https://gist.github.com/chriseppstein/1561650