Anomaly Formula: Percentage By Median
What it does:
This rule compares the latest value with the median of all previous values in your usage history. If the percentage difference from the median meets or exceeds your defined threshold, and the direction matches your selected change type, the rule triggers an anomaly alert.
When to use it:
Use this formula to detect meaningful changes relative to your typical usage, while reducing the effect of outliers. It’s ideal when your history includes occasional spikes or dips you want to ignore.
Mathematical Formula:
Let:
• L = Latest Value
• M = Median of historical values (excluding latest)
• T = Threshold (as a percentage)
• %Δ = Percentage Change
• %Δ = (|L − M| / M) × 100
Anomaly Condition:
%Δ ≥T
Direction Validation (based on Change Type):
• If Change Type = Increased, condition is valid only if L > M
• If Change Type = Decreased, condition is valid only if L < M
• If Change Type = Any, direction check is not required
Outcomes:
Anomaly Detected → %Δ ≥ T and direction matches Change Type
Skipped → %Δ ≥ T, but direction does not match Change Type
Normal → %Δ < T
Examples:
Example 1
Change Type: Increased
Threshold: 10%
History: 100, 105, 115
- If Latest Value = 112
Result: Normal
Explanation:
M = 105
%Δ = (112 − 105) / 105 × 100 = 6.67%
Percentage Change (6.67%) < Threshold (10%)
- If Latest Value = 120
Result: Anomaly Detected
Explanation:
M = 105
%Δ = (120 − 105) / 105 × 100 = 14.29%
Percentage Change (14.29%) ≥ Threshold (10%)
- If Latest Value = 90
Result: Skipped
Explanation:
M = 105
%Δ = |90 − 105| / 105 × 100 = 14.29%
Percentage Change (14.29%) ≥ Threshold (10%)
But direction = Decrease → does not match “Increased”
Example 2
Change Type: Decreased
Threshold: 15%
History: 250, 230, 260
- If Latest Value = 240
Result: Normal
Explanation:
M = 250
%Δ = (250 − 240) / 250 × 100 = 4.00%
Percentage Change (4.00%) < Threshold (15%)
- If Latest Value = 200
Result: Anomaly Detected
Explanation:
M = 250
%Δ = (250 − 200) / 250 × 100 = 20%
Percentage Change (20%) ≥ Threshold (15%)
- If Latest Value = 270
Result: Skipped
Explanation:
M = 250
%Δ = (270 − 250) / 250 × 100 = 8.00%
Percentage Change (8.00%) < Threshold (15%)
Also direction = Increase → does not match “Decreased”
Example 3
Change Type: Any
Threshold: 25%
History: 600, 660, 690
- If Latest Value = 700
Result: Normal
Explanation:
M = 660
%Δ = (700 − 660) / 660 × 100 = 6.06%
Percentage Change (6.06%) < Threshold (25%)
- If Latest Value = 850
Result: Anomaly Detected
Explanation:
M = 660
%Δ = (850 − 660) / 660 × 100 = 28.79%
Percentage Change (28.79%) ≥ Threshold (25%)