R/mutateBits.R

Defines functions mutateBits

# 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
}

Try the mlr package in your browser

Any scripts or data that you put into this service are public.

mlr documentation built on June 22, 2024, 10:51 a.m.