added implementation of getting a random number with countable probability