public double CalculateAverage(List <double> values) { var temp = new DoubleListEventArgs(values); this.OnState(this, temp); return(temp.Result); }
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; }
protected virtual void OnState(object sender, DoubleListEventArgs e) { this.AveragingMethod?.Invoke(sender, e); }
private void MeanMethod(object sender, DoubleListEventArgs args) { args.Result = args.Values.Sum() / args.Values.Count; }