Anomaly Formula: Grubbs Test

What it does:

This rule identifies whether the latest value is a statistical outlier compared to the rest of your history using the Grubbs test. It measures how far the latest value deviates from the mean in terms of standard deviation.

 

When to use it:

Use this when you want to flag extreme outliers that might represent unexpected spikes or drops in usage, based on traditional statistical definitions of abnormality.

 


Mathematical Formula:

 

Let:

• L = Latest Value
 H = Historical Values (excluding L)
 μ = Mean of H
 σ = Standard Deviation of H
 G = Grubbs Score
 T = Threshold
 G = |L − μ| / σ

 

Anomaly Condition:

G ≥ T

 

Direction Validation (based on Change Type):

• If Change Type = Increased, condition is valid only if  L > μ
• If Change Type = Decreased, condition is valid only if  L < μ
• If Change Type = Any, direction check is not required

 

Outcomes:

❌ Anomaly Detected → G ≥ T and direction matches Change Type
☑️ Skipped → G ≥ T but direction does not match Change Type
✅ Normal → G < T

 


Examples:

 

Example 1

Change Type: Increased
Threshold: 2
History: 100, 105, 110, 95

 

  • If Latest Value = 108
    Result: Normal ✅
    Explanation:
      μ = 102.5, σ ≈ 6.45
      G = |108 − 102.5| / 6.45 ≈ 0.85
      G (0.85) < Threshold (2)

 

  • If Latest Value = 120
    Result: Anomaly Detected ❌
    Explanation:
      μ = 102.5, σ ≈ 6.45
      G = |120 − 102.5| / 6.45 ≈ 2.71
      G (2.71) ≥ Threshold (2)

 

  • If Latest Value = 85
    Result: Skipped ☑️
    Explanation:
      μ = 102.5, σ ≈ 6.45
      G = |85 − 102.5| / 6.45 ≈ 2.71
      G (2.71) ≥ Threshold (2)
      But direction = Decrease → does not match “Increased”

Example 2
Change Type: Decreased
Threshold: 2.5
History: 200, 190, 210, 195

 

  • If Latest Value = 193
    Result: Normal ✅
    Explanation:
      μ = 198.75, σ ≈ 8.54
      G = |193 − 198.75| / 8.54 ≈ 0.67
      G (0.67) < Threshold (2.5)

 

  • If Latest Value = 170
    Result: Anomaly Detected ❌
    Explanation:
      μ = 198.75, σ ≈ 8.54
      G = |170 − 198.75| / 8.54 ≈ 3.37
      G (3.37) ≥ Threshold (2.5)

 

  • If Latest Value = 225
    Result: Skipped ☑️
    Explanation:
      μ = 198.75, σ ≈ 8.54
      G = |225 − 198.75| / 8.54 ≈ 3.07
      G (3.07) ≥ Threshold (2.5)
      But direction = Increase → does not match “Decreased”

Example 3
Change Type: Any
Threshold: 3
History: 60, 65, 70, 75

 

  • If Latest Value = 72
    Result: Normal ✅
    Explanation:
      μ = 67.5, σ ≈ 6.45
      G = |72 − 67.5| / 6.45 ≈ 0.70
      G (0.70) < Threshold (3)

 

  • If Latest Value = 45
    Result: Anomaly Detected ❌
    Explanation:
      μ = 67.5, σ ≈ 6.45
      G = |45 − 67.5| / 6.45 ≈ 3.49
      G (3.49) ≥ Threshold (3)