Created
November 27, 2017 14:23
-
-
Save fedden/1e8860543c44fe717cec976d37952ee4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mutate(dna, mutation_sigma, mutation_rate): | |
# If random dice roll (between zero and one) is less than mutation | |
# rate (between zero and one) then inject noise into the dna. | |
if np.random.random_sample() < mutation_rate: | |
# The noise is scaled by the mutation_sigma. | |
dna += np.random.standard_normal(size=dna.shape) * mutation_sigma | |
return dna |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment