public class TrainingMetrics<T>
     where T : INumber<T>, IExponentialFunctions<T>, ITrigonometricFunctions<T>, ILogarithmicFunctions<T>, IFloatingPointIeee754<T>, IRootFunctions<T>
 {
     private int _batchCount = 0;
     private T _m2 = T.Zero; // For incremental variance calculation

     public int Epoch { get; set; }
     public T AverageError { get; private set; } = T.Zero;
     public T MinError { get; private set; } = T.Zero;
     public T MaxError { get; private set; } = T.Zero;
     public T StandardDeviation { get; private set; } = T.Zero;
     public T Variance { get; private set; } = T.Zero;
     public T SumError { get; private set; } = T.Zero;
     public T Range { get; private set; } = T.Zero;
     public T MedianError { get; private set; } = T.Zero;
     public T ModeError { get; private set; } = T.Zero;
     public T MeanAbsoluteDeviation { get; private set; } = T.Zero;
     public T Skewness { get; private set; } = T.Zero;
     public T Kurtosis { get; private set; } = T.Zero;
     public T Percentile25 { get; private set; } = T.Zero;
     public T Percentile75 { get; private set; } = T.Zero;
     public T InterquartileRange { get; private set; } = T.Zero;

     public TimeSpan EpochDuration { get; set; }

     

     public void AddBatchError(T error)
     {
         _batchCount++;

         // Update sum
         SumError += error;

         // Initialize MinError and MaxError on the first error
         if (_batchCount == 1)
         {
             MinError = error;
             MaxError = error;
         }
         else
         {
             // Update min and max
             if (error.CompareTo(MinError) < 0)
                 MinError = error;

             if (error.CompareTo(MaxError) > 0)
                 MaxError = error;
         }

         // Update mean and variance incrementally using Welford's algorithm
         var delta = error - AverageError;
         AverageError += delta / T.CreateTruncating(_batchCount);
         var delta2 = error - AverageError;
         _m2 += delta * delta2;

         Variance = _m2 / T.CreateChecked(_batchCount);
         StandardDeviation = T.Sqrt(Variance);

         //    // Calculate Variance and Standard Deviation
         //    T varianceSum = T.Zero;
         //    foreach (var error in _batchErrors)
         //    {
         //        var diff = error - AverageError;
         //        varianceSum += diff * diff;
         //    }
         //    Variance = varianceSum / T.CreateChecked(_batchErrors.Count);
         //    StandardDeviation = T.Sqrt(Variance);

         //    // Additional metrics like Median, Mode, etc., can be calculated similarly
         //    // For brevity, they are not fully implemented here
     }

     public void Clear()
     {
         AverageError = T.Zero;
         MinError = T.Zero;
         MaxError = T.Zero;
         StandardDeviation = T.Zero;
         Variance = T.Zero;
         SumError = T.Zero;
         _batchCount = 0;
         _m2 = T.Zero;
     }
}
according to best practices in coding and numerical computing, let's improve this class and implement the rest of Metrics to represent better data that would help in debugging and fine tuning neural networks