Revision b57049d9ae4b73b8de7d012d648e7cca9a6478bc authored by pat-s on 22 January 2020, 12:41:32 UTC, committed by pat-s on 22 January 2020, 12:41:32 UTC
1 parent 141ae03
Raw File
mutateBits.R
# Takes a bit string and flips its elements based on a given mutation rate.
#

mutateBits = function(x, rate = 1 / length(x)) {
  n = length(x)
  flip = rbinom(n, 1, rate)
  (x + flip) %% 2
}
back to top