public override double Mutate(double value) { // Mutation equation Vm = V * s * r * 2^(-uk) // where s = sign = {-1, +1) uniform random // r = range // u = [0..1] uniform random // k = precision int toss = Rng.DiscreteUniformZeroOrOne(); int sign = (toss == 0) ? -1 : +1; double u = Rng.ContinuousUniformZeroToOne(); value += sign * r * Math.Pow(2.0, -u * k); return(value); }
/// <summary> /// Randomly rotate or mirror the training sample matrix in-place /// to remove orientation bias. /// </summary> /// <param name="matrix">The matrix to be processed</param> /// <returns>The randomly modified matrix</returns> private void DeBiasMatrix(double[] matrix, int centre, int matrixWidth) { // Flip X if (Rng.DiscreteUniformZeroOrOne() == 1) { FlipP(matrix, centre, matrixWidth); } // Flip Y if (Rng.DiscreteUniformZeroOrOne() == 1) { FlipQ(matrix, centre, matrixWidth); } // TODO: Could add rotation here or instead }