Beispiel #1
0
        public double CalculateAverage(List <double> values)
        {
            var temp = new DoubleListEventArgs(values);

            this.OnState(this, temp);

            return(temp.Result);
        }
Beispiel #2
0
        public void MedianMethod(object sender, DoubleListEventArgs args)
        {
            var sortedValues = args.Values.OrderBy(x => x).ToList();

            int n = sortedValues.Count;

            if (n % 2 == 1)
            {
                args.Result = sortedValues[(n - 1) / 2];
                return;
            }

            args.Result = (sortedValues[sortedValues.Count / 2 - 1] + sortedValues[n / 2]) / 2;
        }
Beispiel #3
0
 protected virtual void OnState(object sender, DoubleListEventArgs e)
 {
     this.AveragingMethod?.Invoke(sender, e);
 }
Beispiel #4
0
 private void MeanMethod(object sender, DoubleListEventArgs args)
 {
     args.Result = args.Values.Sum() / args.Values.Count;
 }