public static Signal IteratedRandomMultiplication(int iterations, int additiveConstant)
 {
     Signal newValues = new Signal(iterations);
     double product = 1;
     for (int i = 0; i < iterations; i++) {
         product *= rand.NextDouble();
         product += (rand.NextDouble()* additiveConstant);
         newValues.Add(product);
     }
     return newValues;
 }
 public static Signal GaussianDistribution(int outputValues, int minVal, int maxVal, int elementsToSum)
 {
     Signal vals = new Signal(outputValues);
     for (int i = 0; i < outputValues; i++) {
         double sum = 0;
         for (int j = 0; j < elementsToSum; j++) {
             sum += rand.Next(minVal, maxVal) + rand.NextDouble();
         }
         vals.Add(sum);
     }
     return vals;
 }
 /// <summary>Sigma is the standard deviation</summary>
 /// <param name="sigma">The standard deviation</param>
 public static Signal GaussianDistribution(int iterations, double sigma = 1)
 {
     //Sigma is the SD
     Signal sig = new Signal();
     for (int i = 0; i < iterations; i++) {
         double r1 = rand.NextDouble();
         double r2 = rand.NextDouble();
         double r = Math.Sqrt(-2 * Math.Log(r1)) * Math.Sin(2 * Math.PI* r2) * sigma;
         sig.Add(r);
     }
     return sig;
 }
 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;
 }
Example #5
0
 public Signal AutoCorrelation()
 {
     Signal ser = new Signal();
     for (int j = 0; j < data.Count() / 2; j++) {
         int numOftests = data.Count() - j;
         double sum = 0;
         var A = 1 / (numOftests * Variance().Sqrd());
         for (int i = 0; i < numOftests; i++) {
             sum += ((data[i] - Mean()) * (data[i + j] - Mean()));
         }
         ser.Add(A*sum);
     }
     return ser;
 }
Example #6
0
 public Signal Transform(Func<double, double> f)
 {
     Signal ser = new Signal(data.Count());
     for(int i=0; i < data.Count(); i++){
         ser.Add(f(data[i]));
     }
     return ser;
 }
Example #7
0
 public Signal SignalAnalysisSignal()
 {
     int numberOfTests = 12;
     Signal newSignal = new Signal(numberOfTests -1);
     for (int i = 1; i < numberOfTests; i++)
         newSignal.Add(Moment(i));
     return newSignal;
 }
Example #8
0
 public Signal RankOrder(int amount)
 {
     Signal sig = new Signal();
     data.Sort();
     data.Reverse();
     for (int i = 0; i < amount; i++) {
         sig.Add(data[i]);
     }
     return sig;
 }
Example #9
0
 public double Moment(int degree)
 {
     Signal signal = new Signal(data.Count());
     double mean = Mean();
     for (int i = 0; i < data.Count(); i++) {
         signal.Add(Math.Pow(data[i] - mean, degree));
     }
     return signal.Mean() / (Math.Pow(StandardDeviation(), degree));
 }
Example #10
0
 public static Signal IterativeFunctionApplication(List<double> seedVals, int iterations)
 {
     Signal newValues = new Signal(seedVals.Count() + iterations);
     for (int i = 0; i < seedVals.Count(); i++) {
         newValues.Add(Math.Log10(seedVals[i]));
     }
     for (int i = 0; i < iterations; i++) {
         double first = Math.Pow(10,Math.Abs(newValues[i]));
         double second = Math.Abs(newValues[i + 1]);
         double third = Math.Abs(newValues[i + 2]);
         switch ((int)first % 4) {
             case 0:
                 newValues.Add(Math.Log10(second + third));
                 break;
             case 1:
                 newValues.Add(Math.Log10(second * third));
                 break;
             case 2:
                 newValues.Add(Math.Log10(second / (third + 1)));
                 break;
             case 3:
                 newValues.Add(Math.Log10(Math.Abs(second - third)));
                 break;
         }
     }
     return newValues;
 }
Example #11
0
 public static Signal RandomNumber(int outputValues, int minVal, int maxVal)
 {
     Signal vals = new Signal(outputValues);
     for (int i = 0; i < outputValues; i++) {
         vals.Add(rand.Next(minVal, maxVal) + rand.NextDouble());
     }
     return vals;
 }
Example #12
0
 /// <summary>P(x) = (mu - 1) /x^ mu</summary>
 public static Signal PowerLawDistribution(int iterations, int mu = 1)
 {
     Signal sig = new Signal();
     for (int i = 0; i < iterations; i++) {
         var a = 1 / rand.NextDouble();
         sig.Add(a);
     }
     return sig;
 }
Example #13
0
 public static Signal PossionDistribution(int iterations, double lambda = 5)
 {
     Signal sig = new Signal();
     for (int i = 0; i < iterations; i++) {
         double p = Math.Exp(-lambda);
         double x = 1;
         int k = -1;
         while (x > p) {
             k++;
             x *= rand.NextDouble();
         }
         sig.Add(k);
     }
     return sig;
 }
Example #14
0
 //Find the probability density function
 //assuming power law, and assuming exponential law
 internal Signal GetSignal()
 {
     Signal signal = new Signal();
     for (int i = 0; i < negativeBins.Count(); i++)
         signal.Add(negativeBins[i]);
     for (int i = 0; i < positiveBins.Count(); i++)
         signal.Add(positiveBins[i]);
     return signal;
 }
Example #15
0
 public Signal GetSeries()
 {
     Signal ser = new Signal();
     foreach (var keyVal in wordCount) {
         ser.Add(keyVal.Value);
     }
     return ser;
 }