private void ComputeSES() { // add first value //SmoothenedData.Add(Demand[0]); // mean of first 12 var sum = 0; for (int i = 0; i < 12; i++) { sum += Demand[i]; Console.WriteLine(Demand[i]); } SmoothenedData.Add((double)sum / 12); // index 0 - 35 for (int i = 1; i < Demand.Count; i++) { double smoothValue = alpha * Demand[i - 1] + (1 - alpha) * SmoothenedData[i - 1]; SmoothenedData.Add(smoothValue); } //forecast // index 36 - 48 for (int i = Demand.Count + 1; i <= Time.Count; i++) { SmoothenedData.Add(SmoothenedData.Last()); } CalculateError(); }
private void ComputeDES() { if (alpha == 0.5f && beta == 0.5f) { Console.WriteLine("test pause"); } //ππ = πΆ * ππ + (π β πΆ) * (ππβπ + ππβπ) //ππ = π· * (ππ β ππβπ) + (π β π·) * ππβπ List <double> s = new List <double>(); List <double> b = new List <double>(); //initialisation s.Add(Demand[1]); //smooth index 1 b.Add(Demand[1] - Demand[0]); // beta index 1 //SmoothenedData.Add(s[0] + b[0]); // t=3 == index 2 // index 1 - 35 for (int i = 1; i < Demand.Count - 1; i++)//begin with (index 3 == t4) compared to (index 0 of DESlist == t3) { var demand = Demand[i + 1]; var previousSmoothing = s[i - 1]; var previousTrend = b[i - 1]; var smooth = alpha * demand + (1 - alpha) * (previousSmoothing + previousTrend); s.Add(smooth); var trend = beta * (s[i] - previousSmoothing) + (1 - beta) * previousTrend; b.Add(trend); SmoothenedData.Add(s[i - 1] + b[i - 1]); // } //forecast //ππ+π = ππ + ππ // index 36 - 48 int forecastCount = 0; for (int i = Demand.Count + 1; i <= Time.Count; i++) { forecastCount++; // ππ+π = π π + ππn // SmoothenedData.Add(s.Last() + (i - Demand.Count) * b.Last()); } CalculateError(); }