package co.phoenixlab.discord.stats;

import static java.lang.Math.*;

public class RunningAverage {

    private double running;
    private int count;
    private double min;
    private double max;

    public RunningAverage() {
        running = 0;
        count = 0;
        min = Double.MAX_VALUE;
        max = 0D;
    }

    public void add(long val) {
        running = (running * (double) count + (double) val) / (double) (count + 1);
        count++;
        min = min(min, val);
        max = max(max, val);
    }

    public void add(int val) {
        running = (running * (double) count + (double) val) / (double) (count + 1);
        count++;
        min = min(min, val);
        max = max(max, val);
    }

    public void add(float val) {
        running = (running * (double) count + (double) val) / (double) (count + 1);
        count++;
        min = min(min, val);
        max = max(max, val);
    }

    public void add(double val) {
        running = (running * (double) count + (double) val) / (double) (count + 1);
        count++;
        min = min(min, val);
        max = max(max, val);
    }

    public double getRunningAverage() {
        return running;
    }

    public int getSize() {
        return count;
    }

    public double getMin() {
        return min;
    }

    public double getMax() {
        return max;
    }

    public String summary() {
        return String.format("%.2f/%.2f/%.2f", min, running, max);
    }
}

@@ -1268,24 +1268,95 @@
  getMin() %7B%0A
+        if (min == Double.MAX_VALUE) %7B%0A            return 0;%0A        %7D%0A
         retu
@@ -1359,24 +1359,24 @@
 return min;%0A
-
     %7D%0A%0A    p
@@ -1486,16 +1486,20 @@
 format(%22
+%25,d 
 %25.2f/%25.2
@@ -1511,25 +1511,58 @@
 f%22, 
-min, running, max
+getSize(), getMin(), getRunningAverage(), getMax()
 );%0A 

Add n to summary, prevent MAX_VALUE returning