def mutGaussian(individual, mu, sigma, indpb):
 size = len(individual)
 if (not isinstance(mu, Sequence)):
  mu = repeat(mu, size)
 elif (len(mu) < size):
  raise IndexError(('mu must be at least the size of individual: %d < %d' % (len(mu), size)))
 if (not isinstance(sigma, Sequence)):
  sigma = repeat(sigma, size)
 elif (len(sigma) < size):
  raise IndexError(('sigma must be at least the size of individual: %d < %d' % (len(sigma), size)))
 for (i, m, s) in zip(xrange(size), mu, sigma):
  if (random.random() < indpb):
   individual[i] += random.gauss(m, s)
 return (individual,)

def mutGaussian ( individual , mu , sigma , indpb ) : size = len ( individual ) if ( not isinstance ( mu , Sequence ) ) : mu = repeat ( mu , size ) elif ( len ( mu ) < size ) : raise IndexError ( ( 'mu must be at least the size of individual: %d < %d' % ( len ( mu ) , size ) ) ) if ( not isinstance ( sigma , Sequence ) ) : sigma = repeat ( sigma , size ) elif ( len ( sigma ) < size ) : raise IndexError ( ( 'sigma must be at least the size of individual: %d < %d' % ( len ( sigma ) , size ) ) ) for ( i , m , s ) in zip ( xrange ( size ) , mu , sigma ) : if ( random . random ( ) < indpb ) : individual [ i ] += random . gauss ( m , s ) return ( individual , )
this function applies a gaussian mutation of mean *mu* and standard deviation *sigma* on the input individual .