Skip to main content
Real series are punctuated by spikes, dips, and sustained level shifts — sensor glitches, promotions, outages. Any SynForecast generator can inject these on demand, so you can measure how a model or an anomaly detector behaves when they appear, with the exact locations known in advance.
Ground-truth labels Set exogenous=ExogenousConfig(anomaly_flags=True) and the output gains an anomaly_flag column marking every injected point. That turns a synthetic series into a labelled benchmark for detection methods. The plots below use it to highlight the injected anomalies in red.

Point anomalies: spikes and dips

Spikes and dips are single-point outliers. anomaly_fraction sets how many points are affected; spike_magnitude and dip_magnitude set their size (in the series’ own units).
Each red marker is an injected outlier that departs sharply from the local trend, then the series resumes as if nothing happened — the signature of a point anomaly.

Level shifts

A level shift is a sustained jump: the series steps to a new level and stays there for level_shift_duration steps. These are harder for models than isolated spikes because they look like a regime change.
The flagged region marks where each shift begins; the elevated plateau that follows is the sustained deviation.

On any generator, including multivariate

Anomaly injection is part of the shared generator pipeline, so it works the same on a seasonal series or a multivariate VAR, where each channel is perturbed independently.

Combine with missing data

Anomalies and missing values compose, so you can build a realistically messy series in one call — outliers to detect and gaps to impute.
Related capabilities
  • Changepoints — structural breaks in level, trend, or variance (a modelled regime change rather than an anomaly).
  • Missingness — random, block, and seasonal gap patterns.
  • The magnitudes and durations here are the common knobs; every anomaly parameter is listed in the generator reference.