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

            this.OnState(this, temp);

            return(temp.Result);
        }
예제 #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;
        }
예제 #3
0
 protected virtual void OnState(object sender, DoubleListEventArgs e)
 {
     this.AveragingMethod?.Invoke(sender, e);
 }
예제 #4
0
 private void MeanMethod(object sender, DoubleListEventArgs args)
 {
     args.Result = args.Values.Sum() / args.Values.Count;
 }