Generate discrete uniform numbers correctly.

The algorithm that was used to calculate discrete uniform numbers
in the range [from, to) was incorrect and resulted in strange values
which were not as random as expected. The new implementation corrects
this problem and also changes the manner in which the solection is done
so that the range for the selection is now [from, to], i.e: the upper
bound is now inclusive.

Signed-off-by: Gary Pamparà <gpampara@gmail.com>