Raxol.Adaptive.TrendDetector (Raxol v2.6.0)

View Source

Pure functional trend detection across aggregate windows.

Computes per-pane slopes for dwell, command, and scroll metrics over the last N aggregates. Returns a map of pane_id to trend data.

No GenServer -- call from LayoutRecommender before applying rules.

Summary

Functions

Compute per-pane trends from a list of aggregates (newest first).

Check if a pane's dwell is trending upward despite currently being low.

Types

trend()

@type trend() :: %{
  dwell_trend: float(),
  command_trend: float(),
  scroll_trend: float()
}

trends()

@type trends() :: %{required(atom()) => trend()}

Functions

compute(aggregates)

@spec compute([map()]) :: trends()

Compute per-pane trends from a list of aggregates (newest first).

Returns %{pane_id => %{dwell_trend: slope, command_trend: slope, scroll_trend: slope}}. Slopes are per-window change rates. Positive = increasing, negative = decreasing. Requires at least 2 aggregates; returns empty map otherwise.

rising?(trends, pane_id, opts \\ [])

@spec rising?(trends(), atom(), keyword()) :: boolean()

Check if a pane's dwell is trending upward despite currently being low.

Useful for suppressing hide recommendations on panes gaining importance.