Gene* GaussianMutation::newLocusValue(Gene* current) { double addend = HierRNG::gaussian(this->mean, this->stdDev); double newIndex = current->getIndex() + addend; Locus* locus = current->getLocus(); if (!this->endReflection) return current->copy(locus->closestIndex(newIndex)); while (locus->outOfRange(newIndex)) { double topIndex = locus->topIndex(); double bottomIndex = locus->bottomIndex(); if (newIndex > topIndex) { newIndex = topIndex - (newIndex - topIndex); } else if (newIndex < bottomIndex) { newIndex = bottomIndex - (newIndex - bottomIndex); } } return current->copy(newIndex); }