### Question:
MathUtil { public static float calcMutatedWeight(Float currentValue, float min, float max, double amplitude) { if (amplitude < 0 || amplitude > 1.0) { throw new IllegalArgumentException("amplitude must be >= 0 and <= 1"); } if (Math.abs(max - min) < 0.0000001) { return min; } float curr; if (currentValue == null) { curr = (max + min) / 2f; } else { curr = currentValue; } curr = (curr < min) ? min : curr; curr = (curr > max) ? max : curr; float distBelow = (float)amplitude * (curr - min); float distAbove = (float)amplitude * (max - curr); float adjustedMin = curr - distBelow; float adjustedMax = curr + distAbove; adjustedMin = (adjustedMin < min) ? min : adjustedMin; adjustedMax = (adjustedMax > max) ? max : adjustedMax; return getRandomFloat(adjustedMin, adjustedMax); }  static float calcMutatedWeight(Float currentValue, float min, float max, double amplitude); static int calcMutatedWeight(Integer currentValue, int min, int max, double amplitude); static float getRandomFloat(float min, float max); static List<ExperimentScorePair> calcFitnessProportions(List<ExperimentScorePair> scorePairs); static Experiment select(List<ExperimentScorePair> fitnessProportions); static boolean equals(float f1, float f2, float delta); static boolean equals(double d1, double d2, float delta); static GAOperation nextGAOperation(GAConfig gaConfig); static int getRandomInt(int min, int max); static ThreadLocalRandom RANDOM; }### Answer:
@Test public void testMutate() { for (int i = 0; i < 100; i++) { float mutated = MathUtil.calcMutatedWeight(2.0f, 0.0f, 10.0f, 1.0f); assertTrue(mutated >= 0.0 && mutated <= 10.0); } for (int i = 0; i < 100; i++) { float mutated = MathUtil.calcMutatedWeight(2.0f, 0.0f, 10.0f, 0.8f); assertTrue(mutated >= 0.4 && mutated <= 8.4); } for (int i = 0; i < 100; i++) { float mutated = MathUtil.calcMutatedWeight(2.0f, 0.0f, 10.0f, 0.1f); assertTrue(mutated >= 1.8 && mutated <= 2.8); } for (int i = 0; i < 100; i++) { float mutated = MathUtil.calcMutatedWeight(null, 0.0f, 10.0f, 0.1f); assertTrue(mutated >= 4.5 && mutated <= 5.5); } for (int i = 0; i < 100; i++) { float mutated = MathUtil.calcMutatedWeight(0.0f, 1.0f, 10.0f, 0.1f); assertTrue(mutated >= 1.0 && mutated <= 1.9); } }