Module iqr

Module iqr 

Source
Expand description

anomaly_score_iqr window function โ€” IQR-based anomaly scoring.

Algorithm:

  • Compute Q1 (25th percentile) and Q3 (75th percentile)
  • IQR = Q3 - Q1
  • Lower fence = Q1 - k * IQR, Upper fence = Q3 + k * IQR
  • If value is outside fences, score = |distance to nearest fence| / IQR
  • Otherwise, score = 0.0

When IQR = 0 (constant quartiles), returns 0.0 if value is on the fence, or +inf if value is outside.

Structsยง

AnomalyScoreIqr
AnomalyScoreIqrEvaluator ๐Ÿ”’

Constantsยง

MIN_SAMPLES ๐Ÿ”’
Minimum valid samples for IQR (linear-interpolated Q1 != Q3 is possible at n >= 3).