mardi 14 juin 2016

How to use random.randint to find random 0 and 1 with not equal propbability

I am using DEAP toolbox in Python for Genetic Algorithm.

toolbox.register("attr_bool", random.randint, 0, 1) 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.

I think srng.binomial(X.shape, p=retain_prob) is a choice, but I want to use random.randint function. Wondering how we can do that?

Aucun commentaire:

Enregistrer un commentaire