/// <summary> /// Calculate current group statistics /// </summary> public void CalculateGroupStatistics() { List <int> mathData = new List <int>(); List <int> physicsData = new List <int>(); List <int> englishData = new List <int>(); foreach (Student item in Students) { mathData.Add(item.Math); physicsData.Add(item.Physics); englishData.Add(item.English); } Statistics.Add("Math", new Statistic(StatisticHelper.Mode(mathData), StatisticHelper.Median(mathData), StatisticHelper.SimpleAverage(mathData))); Statistics.Add("Physics", new Statistic(StatisticHelper.Mode(physicsData), StatisticHelper.Median(physicsData), StatisticHelper.SimpleAverage(physicsData))); Statistics.Add("English", new Statistic(StatisticHelper.Mode(englishData), StatisticHelper.Median(englishData), StatisticHelper.SimpleAverage(englishData))); }
/// <summary> /// Calculate statistics for all data, using StatisticHelper class for mode,median and average calculations /// </summary> public void CalculateDataStatistics() { List <int> mData = new List <int>(); List <int> pData = new List <int>(); List <int> eData = new List <int>(); foreach (Group item in Groups.Values) { for (int i = 0; i < item.GetStudentsCount; i++) { mData.Add(item.GetStudent(i).Math); pData.Add(item.GetStudent(i).Physics); eData.Add(item.GetStudent(i).English); } } Statistics.Add("Math", new Statistic(StatisticHelper.Mode(mData), StatisticHelper.Median(mData), StatisticHelper.SimpleAverage(mData))); Statistics.Add("Physics", new Statistic(StatisticHelper.Mode(pData), StatisticHelper.Median(pData), StatisticHelper.SimpleAverage(pData))); Statistics.Add("English", new Statistic(StatisticHelper.Mode(eData), StatisticHelper.Median(eData), StatisticHelper.SimpleAverage(eData))); }