Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Simple ¶
type Simple struct {
// contains filtered or unexported fields
}
Simple keeps track of a history of measurements and returns the average. One important feature of this implementation is that the average can go to zero. All methods are thread safe.
Alternative: consider exponential moving average where near-zero values are treated as zero (for scale to zero):
func MovingExpAvg(value, oldValue, fdtime, ftime float64) float64 { alpha := 1.0 - math.Exp(-fdtime/ftime) r := alpha * value + (1.0 - alpha) * oldValue return r }
Click to show internal directories.
Click to hide internal directories.