package co.phoenixlab.discord.stats;

public class RunningAverage {

    private double running;
    private int count;

    public RunningAverage() {
        running = 0;
        count = 0;
    }

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

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

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

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

    public double getRunningAverage() {
        return running;
    }

    public int getSize() {
        return count;
    }
}

@@ -31,16 +31,49 @@
 stats;%0A%0A
+import static java.lang.Math.*;%0A%0A
 public c
@@ -145,16 +145,64 @@
 t count;
+%0A    private double min;%0A    private double max;
 %0A%0A    pu
@@ -261,24 +261,74 @@
  count = 0;%0A
+        min = Double.MAX_VALUE;%0A        max = 0D;%0A
     %7D%0A%0A    p
@@ -447,32 +447,90 @@
        count++;%0A
+        min = min(min, val);%0A        max = max(max, val);%0A
     %7D%0A%0A    publi
@@ -644,32 +644,90 @@
        count++;%0A
+        min = min(min, val);%0A        max = max(max, val);%0A
     %7D%0A%0A    publi
@@ -843,32 +843,90 @@
        count++;%0A
+        min = min(min, val);%0A        max = max(max, val);%0A
     %7D%0A%0A    publi
@@ -1047,24 +1047,82 @@
    count++;%0A
+        min = min(min, val);%0A        max = max(max, val);%0A
     %7D%0A%0A    p
@@ -1210,24 +1210,24 @@
 getSize() %7B%0A
-
         retu
@@ -1241,11 +1241,227 @@
 t;%0A    %7D
+%0A%0A    public double getMin() %7B%0A        return min;%0A    %7D%0A%0A    public double getMax() %7B%0A        return max;%0A    %7D%0A%0A    public String summary() %7B%0A        return String.format(%22%25.2f/%25.2f/%25.2f%22, min, running, max);%0A    %7D
 %0A%7D%0A

Add min max summary to RunningAverage