Lambda : History-Aware Bayesian Jump Event Detector for Time Series (with Dual EYE Mode)




Introduction: Why a New Perspective?

Have you ever felt that traditional time-series anomaly detection methods just don’t cut it—especially for systems with sudden shocks, structural breaks, or rare but critical “jumps”?
Most existing methods treat the world as either smooth (changepoint) or noisy (outlier)—but ignore the reality that meaningful events (jumps) drive the evolution of many systems.



Lambda³ is a new, open-source Bayesian model that tackles this head-on:

  • It doesn’t just fit a curve to data.
  • It separates “smooth trends” and “jump events” as coexisting processes.
  • It explains why and with what certainty each event happens.



Dual EYE Mode: Global and Local Event Detection

Global Eye: Detects history-wide, statistically significant jumps (ΔΛC) using global percentiles.
Captures major regime changes, like market crashes or phase transitions.

Local Eye: Detects context-sensitive, locally surprising jumps using moving-window normalization.
Ideal for catching subtle precursors or micro-anomalies—potential early warnings.



Both types are visualized:

  • Blue/Orange: Global (macro) positive/negative jumps
  • Magenta: Local (micro) contextual jumps



Why Lambda³? (What’s different?)

Method Detects? Explains? Handles direction/magnitude? Real-world use
Changepoint Trend/process shifts No No Regime shifts
Outlier Rare/extreme points No No Data cleaning
Jump Event (Lambda³) Sudden, explainable events Yes Yes Shocks, anomalies, system events



Example Output

Image description

Image description



Code Example

# ===============================
# 2. Lambda³ Feature Extraction
# ===============================
def calc_lambda3_features_v2(data, config: L3Config):
    """
    Extracts Lambda³ features:
    - Global jump events (Delta_LambdaC, based on global percentile)
    - Local jump events (local_jump_detect, based on local z-score style thresholding)
    - Local volatility (rho_T)
    - Linear time trend
    """
    # --- Global (history-wide) jump detection ---
    diff = np.diff(data, prepend=data[0])
    threshold = np.percentile(np.abs(diff), config.delta_percentile)
    delta_LambdaC_pos = (diff > threshold).astype(int)
    delta_LambdaC_neg = (diff < -threshold).astype(int)

    # --- Local jump detection (contextual anomaly) ---
    local_std = np.array([
        data[max(0, i-config.local_window):min(len(data), i+config.local_window+1)].std()
        for i in range(len(data))
    ])
    score = np.abs(diff) / (local_std + 1e-8)
    local_threshold = np.percentile(score, config.local_jump_percentile)
    local_jump_detect = (score > local_threshold).astype(int)

    # --- Local volatility feature (rho_T) ---
    rho_T = np.array([data[max(0, i-config.window):i+1].std() for i in range(len(data))])
    time_trend = np.arange(len(data))

    return delta_LambdaC_pos, delta_LambdaC_neg, rho_T, time_trend, local_jump_detect

# ===============================
# 3. Lambda³ Bayesian Regression Model
# ===============================
def fit_l3_bayesian_regression_v2(data, delta_LambdaC_pos, delta_LambdaC_neg, rho_T, time_trend, config: L3Config):
    """
    Bayesian regression: fits model to data using Lambda³ features.
    Estimates coefficients for global trend, positive jumps, negative jumps, and local volatility.
    """
    with pm.Model() as model:
        beta_0 = pm.Normal('beta_0', mu=0, sigma=2)
        beta_time = pm.Normal('beta_time', mu=0, sigma=1)
        beta_dLC_pos = pm.Normal('beta_dLC_pos', mu=0, sigma=5)
        beta_dLC_neg = pm.Normal('beta_dLC_neg', mu=0, sigma=5)
        beta_rhoT = pm.Normal('beta_rhoT', mu=0, sigma=3)

        mu = (beta_0
              + beta_time * time_trend
              + beta_dLC_pos * delta_LambdaC_pos
              + beta_dLC_neg * delta_LambdaC_neg
              + beta_rhoT * rho_T)

        sigma_obs = pm.HalfNormal('sigma_obs', sigma=1)
        y_obs = pm.Normal('y_obs', mu=mu, sigma=sigma_obs, observed=data)
        trace = pm.sample(draws=config.draws, tune=config.tune, target_accept=config.target_accept)
    return trace

Enter fullscreen mode

Exit fullscreen mode



Features & Design Philosophy

Directional event detection (positive/negative)

  • Full Bayesian coefficient estimation
  • Transaction-indexed time (not just “physical” time)
  • Minimal code, MIT license
  • Made for both rapid prototyping and theory exploration



Theory & Vision

Lambda³ is more than just a detector—it’s a new way of thinking about time-series events:

Treats events as structural, meaningful “transactions” that drive system evolution

Fuses explainable AI, information theory, and statistical physics

The goal?
“Not just when or where, but why—with quantified confidence.”



Join the Community

GitHub Repo
→ Star, fork, or PR welcome!

  • Issues/Ideas/Use cases? Drop a comment or open an issue.
  • Discussion, demos, and “event detection stories” wanted!



Author & Contact

Iizumi Masamichi
Science is not property; it’s a shared horizon. Let’s redraw the boundaries, together.



Source link