mardi 28 novembre 2017

How to randomly alter an array based on an if statement as if mutating a gene in a genetic algorithm?

mutation_rate=.05 and current_pop is an array. How can I make this if statement randomly change values within the array? This is mutation in a genetic algorithm. Thanks for the help!

    for i in range(len(current_pop)):
        r= np.random.rand() 
        if r < mutation_rate: 

    return new_array

`




Aucun commentaire:

Enregistrer un commentaire