From 356517f2e84809f0c1945b4361c37338b3cc66a8 Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:03:18 +0530 Subject: [PATCH] Fix BoxCoxTransform inverse for negative lambda values The _invert method used `if lmbda > 0` to decide between the power formula and the exponential. This caused negative lambda values to incorrectly fall through to the `exp` branch, which is only valid for lmbda == 0. The Box-Cox inverse for any non-zero lambda is `(lmbda * y + 1) ** (1 / lmbda)`, regardless of sign. Changed the condition to `if lmbda != 0` so that negative lambdas (common for heavy-tailed time series) are inverted correctly. --- merlion/transform/normalize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merlion/transform/normalize.py b/merlion/transform/normalize.py index 115a8c20e..7d1aba5db 100644 --- a/merlion/transform/normalize.py +++ b/merlion/transform/normalize.py @@ -200,7 +200,7 @@ def _invert(self, time_series: TimeSeries) -> TimeSeries: new_vars = [] for name, var in time_series.items(): lmbda = self.lmbda[name] - if lmbda > 0: + if lmbda != 0: var = (lmbda * var + 1) ** (1 / lmbda) nanvals = var.isna() if nanvals.any():