--- from: http://rosettacode.org/wiki/Modified_random_distribution