public static double Calculate(IEnumerable <double> originalValues, IEnumerable <double> estimatedValues, out OnlineCalculatorError errorState)
        {
            IEnumerator <double>             originalEnumerator  = originalValues.GetEnumerator();
            IEnumerator <double>             estimatedEnumerator = estimatedValues.GetEnumerator();
            OnlineMaxAbsoluteErrorCalculator maeCalculator       = new OnlineMaxAbsoluteErrorCalculator();

            // always move forward both enumerators (do not use short-circuit evaluation!)
            while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext())
            {
                double original  = originalEnumerator.Current;
                double estimated = estimatedEnumerator.Current;
                maeCalculator.Add(original, estimated);
                if (maeCalculator.ErrorState != OnlineCalculatorError.None)
                {
                    break;
                }
            }

            // check if both enumerators are at the end to make sure both enumerations have the same length
            if (maeCalculator.ErrorState == OnlineCalculatorError.None &&
                (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext()))
            {
                throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
            }
            else
            {
                errorState = maeCalculator.ErrorState;
                return(maeCalculator.MaxAbsoluteError);
            }
        }
 protected OnlineMaxAbsoluteErrorCalculator(OnlineMaxAbsoluteErrorCalculator original, Cloner cloner = null)
     : base(original, cloner)
 {
     mae        = original.mae;
     n          = original.n;
     errorState = original.errorState;
 }
    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
      IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
      IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
      OnlineMaxAbsoluteErrorCalculator maeCalculator = new OnlineMaxAbsoluteErrorCalculator();

      // always move forward both enumerators (do not use short-circuit evaluation!)
      while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
        double original = originalEnumerator.Current;
        double estimated = estimatedEnumerator.Current;
        maeCalculator.Add(original, estimated);
        if (maeCalculator.ErrorState != OnlineCalculatorError.None) break;
      }

      // check if both enumerators are at the end to make sure both enumerations have the same length
      if (maeCalculator.ErrorState == OnlineCalculatorError.None &&
         (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
      } else {
        errorState = maeCalculator.ErrorState;
        return maeCalculator.MaxAbsoluteError;
      }
    }