title: Numpy Array random mutation
body: <p>I'm coding my first genetic algorithm in Python.
  I particularly care about the optimization and population scalability.</p>
  
  <pre><code>import numpy as np
  population = np.random.randint(-1, 2, size=(10,10))
  </code></pre>
  
  <p>Here I make a [10,10] array, with random number between -1 and 1.<br>
  And now I want to perform a specific mutation ( mutation rate depends on the specimens fitness ) for each specimen of my array. </p>
  
  <p>For example, I have:</p>
  
  <pre><code>print population
  [[ 0  0  1  1 -1  1  1  0  1  0]
  [ 0  1 -1 -1  0  1 -1 -1  0 -1]
  [ 0  0  0  0  0  0  0  0  0  0]
  [ 0  0  0  0  0  0  0  0  0  0]
  [ 0  0  0  0  0  0  0  0  0  0]
  [ 0  1  1  0  0  0  1  1  0  1]
  [ 1 -1  0  0  1  0 -1  1  1  0]
  [ 1 -1  1 -1  0 -1  0  0  1  1]
  [ 0  0  0  0  0  0  0  0  0  0]
  [ 0  1  1  0  0  0  1 -1  1  0]]
  </code></pre>
  
  <p>I want to perform the mutation of this array with a specific mutation rate for each sub-array in population. I try this but the optimization is not perfect and I need to perform a different mutation for each sub-array (each sub-array is a specimen) in the population (the main array, "population").</p>
  
  <pre><code>population[0][numpy.random.randint(0, len(population[0]), size=10/2)] = np.random.randint(-1, 2, size=10/2)
  </code></pre>
  
  <p>I'm looking for a way to apply something like a mutation mask on all the main-array. Something like that:</p>
  
  <pre><code> population[array element select with the mutation rate] = random_array[with the same size]
  </code></pre>
  
  <p>I think it's the best way (because we only to an array selection and after we replace this selection with the random array), but I don't know how to perform this. And if you have other solution I am on it ^^.</p>