private String mutateString ( String s , Random rng ) { StringBuilder buffer = new StringBuilder ( s ) ; for ( int i = 0 ; i < buffer . length ( ) ; i ++ ) { if ( mutationProbability . nextValue ( ) . nextEvent ( rng ) ) { buffer . setCharAt ( i , alphabet [ rng . nextInt ( alphabet . length ) ] ) ; } } return buffer . toString ( ) ; }
Mutate a single string . Zero or more characters may be modified . The probability of any given character being modified is governed by the probability generator configured for this mutation operator .