aboutsummaryrefslogtreecommitdiff
path: root/stats.go
diff options
context:
space:
mode:
Diffstat (limited to 'stats.go')
-rw-r--r--stats.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/stats.go b/stats.go
index ffe94eb..46ddc99 100644
--- a/stats.go
+++ b/stats.go
@@ -40,6 +40,8 @@ import (
// several methods are exposed in order to make your life easy
type Stats struct {
n, m1, m2, m3, m4 float64
+ Max float64
+ Min float64
}
// Zeros out the struct for re-use
@@ -53,6 +55,13 @@ func (s *Stats) Clear() {
func (s *Stats) Push(x float64) {
var delta, delta_n, delta_n2, term1, n1 float64
+ if x >= s.Max {
+ s.Max = x
+ }
+ if x <= s.Min {
+ s.Min = x
+ }
+
n1 = s.n
s.n++
delta = x - s.m1