Beispiel #1
0
        public void BackgroundThread()
        {
            if (_uniformMode)
            {
                while (!_requestStop)
                {
                    ReportNumber(_rnd.NextDouble());
                }
            }
            else
            {
                while (!_requestStop)
                {
                    ReportNumber(_rnd.NextGaussian());
                }
            }

            Action a = () =>
            {
                ButtonStart.IsEnabled       = true;
                ButtonStop.IsEnabled        = false;
                ComboDistribution.IsEnabled = true;
                ComboGenerator.IsEnabled    = true;
            };

            Dispatcher.BeginInvoke(a);
        }
Beispiel #2
0
 /// <summary>
 ///     Randomly move to a new location.  To specify a new randomization function, override this method.
 /// </summary>
 /// <param name="memory">The long term memory.</param>
 public void PerformRandomize(double[] memory)
 {
     for (var i = 0; i < memory.Length; i++)
     {
         var d = _rnd.NextGaussian() * 3;
         memory[i] += d;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Sample new parameters.
 /// </summary>
 private void SampleSolutions()
 {
     for (int i = _populationSize; i < _population.Length; i++)
     {
         int pdf = SelectPDF();
         for (int j = 0; j < _paramCount; j++)
         {
             double sigma = ComputeSD(j, pdf);
             double mu    = _population[pdf].Params[j];
             double d     = (Random.NextGaussian() * sigma) + mu;
             _population[i].Params[j] = d;
         }
     }
 }