Exemplo n.º 1
0
 private void propagateSignal(Signal excitedNodes)
 {
     for (int i = 0; i < excitedNodes.Count(); i++) {
         int nodeToExcite = (int)(excitedNodes[i] * propagationStrength[i] + excitedNodes.Count()) % excitationState.Count();
         excitationState[nodeToExcite] *= excitedNodes[i] * propagationStrength[i];
     }
 }
Exemplo n.º 2
0
 /// <summary>Uses Scott's choice algorithm to assign bin width:
 /// http://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width</summary>
 public Histogram(Signal data)
 {
     this.data = data;
     var bS = (3.5 * data.StandardDeviation()) / Math.Pow(data.Count(), .33333333333333);
     if(bS <= 0)
         bS = .01;
     this.binSize = bS;
     for (int i = 0; i < data.Count(); i++) {
         IncrementAt((int)Math.Floor(data[i] / binSize));
     }
 }
Exemplo n.º 3
0
 public Histogram(Signal data, double binSize)
 {
     this.data = data;
     this.binSize = binSize;
     for (int i = 0; i < data.Count(); i++) {
         IncrementAt((int)Math.Floor(data[i] / binSize));
     }
 }
Exemplo n.º 4
0
 public static Signal CityDevelopment(int startingCities, int iterations, double b = .1)
 {
     Signal cities = new Signal();
     for (int i = 0; i < startingCities; i++) {
         cities.Add(1);
     }
     for (int i = 0; i < iterations - startingCities; i++) {
         if (rand.NextDouble() < b) {
             cities.Add(1);
         } else {
             var randNum = (double)rand.Next(0, i+startingCities);
             for (int j = 0; j < cities.Count(); j++) {
                 randNum -= cities[j];
                 if (randNum < 0) {
                     cities[j]++;
                     break;
                 }
             }
         }
     }
     return cities;
 }