Ejemplo n.º 1
0
        public double[] Mutate(double[] vector)
        {
            for (int i = 0; i < vector.Length; i++)
            {
                if (ProbabilityUtils.P(1.0 / vector.Length))
                {
                    vector[i] = ProbabilityUtils.GaussianDistribution(standardDeviation, vector[i]).Clip(minValue, maxValue);
                }
            }

            return(vector);
        }
        public int[] Mutate(int[] vector)
        {
            var mean = (maxValue + minValue) / 2.0;

            for (int i = 0; i < vector.Length; i++)
            {
                if (ProbabilityUtils.P(1.0 / vector.Length))
                {
                    vector[i] = (int)ProbabilityUtils.GaussianDistribution(standardDeviation, mean).Clip(minValue, maxValue);
                }
            }

            return(vector);
        }
Ejemplo n.º 3
0
        public void GaussianDistribution_CommonNumbersAreMoreLikely(double mean, double sd)
        {
            var smallCount = 0;
            var bigCount   = 0;

            for (int i = 0; i < 100; i++)
            {
                var value = ProbabilityUtils.GaussianDistribution(sd, mean);
                Console.WriteLine(value);
                if (value >= mean + sd || value <= mean - sd)
                {
                    bigCount++;
                }
                else
                {
                    smallCount++;
                }
            }

            Assert.IsTrue(smallCount > bigCount, $"Got to many big genomes. Big numberes = {bigCount}; small numbers = {smallCount}");
        }