Added random number generator

Added random number generator, taken from https://gist.github.com/chriseppstein/1561650, all credit to him.