Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateDeviationPct ¶
CalculateDeviationPct computes relative percentage change from baseline.
func CalculateZScore ¶
CalculateZScore computes Z-score: (x - mean) / stddev.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector tracks multiple metric streams and identifies statistical anomalies using Z-score and EWMA.
func NewDetector ¶
func NewDetector(cfg *config.AnomalyConfig) *Detector
NewDetector creates a statistical anomaly detector.
func (*Detector) Feed ¶
Feed ingests a single metric point, updates baseline stats, and evaluates anomaly score.
func (*Detector) FeedSnapshot ¶
func (d *Detector) FeedSnapshot(snapshot *model.SystemSnapshot) *model.AnomalyReport
FeedSnapshot extracts all standard metrics from a snapshot and evaluates anomalies.
type EWMATracker ¶
type EWMATracker struct {
// contains filtered or unexported fields
}
EWMATracker computes Exponentially Weighted Moving Average.
func NewEWMATracker ¶
func NewEWMATracker(alpha float64) *EWMATracker
NewEWMATracker creates an EWMA calculator with smoothing factor alpha (0.0 < alpha <= 1.0).
func (*EWMATracker) Update ¶
func (e *EWMATracker) Update(val float64) float64
Update incorporates a new sample and returns the new EWMA.
type MetricStream ¶
type MetricStream struct {
// contains filtered or unexported fields
}
MetricStream holds statistical estimators for a single time series metric.
type RollingWindow ¶
type RollingWindow struct {
// contains filtered or unexported fields
}
RollingWindow maintains a fixed-size ring buffer for statistical calculations.
func NewRollingWindow ¶
func NewRollingWindow(capacity int) *RollingWindow
NewRollingWindow creates a rolling window buffer with maximum capacity.
func (*RollingWindow) Add ¶
func (rw *RollingWindow) Add(val float64)
Add appends a new data point into the rolling window.
func (*RollingWindow) Count ¶
func (rw *RollingWindow) Count() int
Count returns the current number of samples in the window.
func (*RollingWindow) Mean ¶
func (rw *RollingWindow) Mean() float64
Mean returns the arithmetic mean of values in the window.
func (*RollingWindow) MinMax ¶
func (rw *RollingWindow) MinMax() (float64, float64)
MinMax returns minimum and maximum values in the window.
func (*RollingWindow) StdDev ¶
func (rw *RollingWindow) StdDev() float64
StdDev computes the sample standard deviation.
func (*RollingWindow) Values ¶
func (rw *RollingWindow) Values() []float64
Values returns a copy of current elements in the window.