Documentation
¶
Index ¶
- func Digits[T int32 | int64](value T) int
- func EstimatedDigitsInt32(value int32) int
- func EstimatedDigitsInt64(value int64) int
- func Log10Func(factor int) func(value int) int
- func Smooth(oldValue, newValue, factor float64) float64
- type CorrelationWindow
- type Ewma
- type EwmaRate
- type MedianFilter
- type RollingSum
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimatedDigitsInt32 ¶
EstimatedDigitsInt32 returns the estimated number of digits required to represent value with base 10. The returned estimation should always be >= that the actual number of digits, but never lower.
func EstimatedDigitsInt64 ¶
EstimatedDigitsInt64 returns the estimated number of digits required to represent value with base 10. The returned estimation should always be >= that the actual number of digits, but never lower.
Types ¶
type CorrelationWindow ¶
type CorrelationWindow struct {
// contains filtered or unexported fields
}
CorrelationWindow can be used to compute correlation for sets of values over a rolling window.
This type is not concurrency safe.
func NewCorrelationWindow ¶
func NewCorrelationWindow(capacity uint, warmupSamples uint8) *CorrelationWindow
func (*CorrelationWindow) Add ¶
func (w *CorrelationWindow) Add(x, y float64) (correlation, cvX, cvY float64)
Add adds the values to the window and returns the current correlation coefficient. Returns a value between 0 and 1 when a correlation between increasing x and y values is present. Returns a value between -1 and 0 when a correlation between increasing x and decreasing y values is present. Returns 0 values if < warmup or low CV (< .01)
type Ewma ¶
type Ewma interface { // Add adds a value to the series and updates the moving average. Add(float64) float64 // Value gets the current value of the moving average. Value() float64 // Set sets a value for the moving average. Set(float64) }
Ewma provides an exponentially weighted moving average for some windowed values, without strict time-based adjustments.
This type is not concurrency safe.
type EwmaRate ¶
type EwmaRate struct {
// contains filtered or unexported fields
}
EwmaRate tracks an exponentially weighted moving average of a per-second rate.
type MedianFilter ¶
type MedianFilter struct {
// contains filtered or unexported fields
}
MedianFilter provides the median value over a rolling window.
This type is not concurrency safe.
func NewMedianFilter ¶
func NewMedianFilter(size int) *MedianFilter
func (*MedianFilter) Add ¶
func (f *MedianFilter) Add(value float64) float64
Add adds a value to the filter, sorts the values, and returns the current median.
func (*MedianFilter) Median ¶
func (f *MedianFilter) Median() float64
Median returns the current median, else 0 if the filter isn't full yet.
type RollingSum ¶
type RollingSum struct {
// contains filtered or unexported fields
}
RollingSum can be used to compute the coefficient of variation over rolling windowed values, along with slope calulation.
This type is not concurrency safe.
func NewRollingSum ¶
func NewRollingSum(capacity uint) *RollingSum
func (*RollingSum) Add ¶
func (r *RollingSum) Add(value float64) (oldValue float64, full bool)
Add adds the value to the window if it's non-zero, updates the sums, and returns the old value along with whether the window is full.
func (*RollingSum) CalculateCV ¶
func (r *RollingSum) CalculateCV() (cv, mean, variance float64)
CalculateCV calculates the coefficient of variation (relative variance), mean, and variance for the sum. Returns NaN values if there are < 2 samples, the variance is < 0, or the mean is 0.