Skip to main content

mutate

Function mutate 

pub fn mutate(
    child: &mut [f64],
    kinds: &[GeneKind],
    eta: f64,
    rate: f64,
    rng: &mut ChaCha8Rng,
)
Expand description

Mutates a child in place, gene by gene, at per-gene probability rate.

A numeric gene is perturbed by polynomial_delta and clamped back into [0, 1]; a categorical gene is re-drawn uniformly over its support (a fresh unit coordinate, which from_unit floors into one of the equal-width choice cells — so every label, including the current one, is equally likely). The customary rate is 1/d, so a child is expected to change in exactly one gene.

Draws exactly two f64 per dimension — a rate coin and a magnitude — whether or not the coin fires, so the stream position depends only on the dimension (see the module documentation).