Пример #1
0
        public override StatisticsData Average(String name, int precision, params StatisticsData[] stats)
        {
            Trace.Assert(stats.Length > 0, "Cannot compute the average of zero elements.");

            // Make sure that the stats we have at least one non-unknown value (otherwise this method will cause an
            // infinite loop
            bool allUnknown = true;
            for (int j = 0; j < stats.Length; j++)
            {
                if (!(stats[j] is StatisticsUnknownData))
                {
                    allUnknown = false;
                    break;
                }
            }

            if (allUnknown) return new StatisticsUnknownData(name);
            else
            {
                // This statistics does not know its value, so we take the first element in the other statistics
                // And calculate the average through them

                StatisticsData[] newParams = new StatisticsData[stats.Length];
                int i;
                for (i = 0; i < stats.Length - 1; i++)
                {
                    newParams[i] = stats[i + 1];
                }
                newParams[i] = this;

                return stats[0].Average(name, precision, newParams);
            }
        }
Пример #2
0
 public Statistic(StatisticsData mainData, String category)
 {
     this.mainData = mainData;
     this.category = category;
     this.Order = 0;
     this.subData = new List<StatisticsData>();
 }
Пример #3
0
 // Wrap around
 public StatisticItem(StatisticsData statisticToDispay, Control parent)
     : this(new Statistic(statisticToDispay, ""), parent)
 {
 }
Пример #4
0
        public Statistic Average(String category, int precision, params Statistic[] stats)
        {
            int paramsCount = stats.Count<Statistic>();

            // Populate param list for main data
            StatisticsData[] mainStats = new StatisticsData[paramsCount];
            for (int i = 0; i < paramsCount; i++)
            {
                mainStats[i] = stats[i].MainData;
            }

            // Compute average for main data
            StatisticsData mainDataAverage = MainData.Average(MainData.Name, precision, mainStats);

            // Assume the sub statistics are ordered and are of the same size of the other sub statistics
            List<StatisticsData> subDataAverages = new List<StatisticsData>();
            for (int i = 0; i < SubData.Count; i++)
            {
                // Populate a param list with the values for each sub value
                StatisticsData[] subStats = new StatisticsData[paramsCount];
                for (int j = 0; j < paramsCount; j++)
                {
                    Trace.Assert(SubData.Count == stats[j].SubData.Count, "Trying to compute the average of sub statistics values when their sizes are different.");
                    subStats[j] = stats[j].SubData[i];
                }

                subDataAverages.Add(SubData[i].Average(SubData[i].Name, precision, subStats));
            }

            return new Statistic(mainDataAverage, category, subDataAverages);
        }
Пример #5
0
 public void AddSubStatistic(StatisticsData subStatistic)
 {
     subData.Add(subStatistic);
 }
Пример #6
0
 public Statistic(StatisticsData mainData, String category, List<StatisticsData> subData)
     : this(mainData, category)
 {
     this.subData = subData;
 }
Пример #7
0
 public Statistic(StatisticsData mainData)
     : this(mainData, "")
 {
 }