How to use random.randint to find random 0 and 1 with not equal propbability <p>I am using <a href="https://pypi.python.org/pypi/deap" rel="nofollow">DEAP</a> toolbox in Python for Genetic Algorithm. </p> <p><code>toolbox.register("attr_bool", random.randint, 0, 1)</code> is a function randomly chooses 0 and 1 for populations in GA. I want to force GA to choose 0 and 1 randomly but with for example 80% one and the rest zero. </p> <p>I think <code>srng.binomial(X.shape, p=retain_prob)</code> is a choice, but I want to use <code>random.randint</code> function. Wondering how we can do that? </p>