Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit 356517f

Browse files
committed
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.
1 parent 085ef8a commit 356517f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

merlion/transform/normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _invert(self, time_series: TimeSeries) -> TimeSeries:
200200
new_vars = []
201201
for name, var in time_series.items():
202202
lmbda = self.lmbda[name]
203-
if lmbda > 0:
203+
if lmbda != 0:
204204
var = (lmbda * var + 1) ** (1 / lmbda)
205205
nanvals = var.isna()
206206
if nanvals.any():

0 commit comments

Comments
 (0)