Implements a random function that returns 1 for x% of the times.