🧰 Library for generating synthetic time series data with anomalies for testing anomaly detection algorithms.
🚧 Work in progress (Anomalies should be as good - bad? - as possible)
Entry point:
main.py
import numpy as np
from generators import NormalGenerator, DriftGenerator
# Generate time series shape
shape = (1000, 3) # 1000 time steps, 3 variates
# Example 1: Add Gaussian noise
normal_gen = NormalGenerator(
shape=shape,
combine_mode="add",
combine_domain="time",
mean=0.0,
std=0.5
)
base_ts = np.zeros(shape)
noisy_ts = normal_gen.generate_and_combine(base_ts)
# Example 2: Add drift
drift_gen = DriftGenerator(
shape=shape,
combine_mode="add",
combine_domain="time",
drift_type="linear",
drift_rate=0.01
)
final_ts = drift_gen.generate_and_combine(spiked_ts)- Time domain addition: Direct addition of anomaly to signal
- Time domain multiplication: Scaling of signal by anomaly factor
- Frequency domain addition: Add anomaly in frequency space (good for spectral anomalies)
- Frequency domain multiplication: Multiply in frequency space (good for filtering effects)
The abstract base class that all generators inherit from. It provides:
- Shape management: Define time series dimensions (sequence length, number of variates)
- Combine operations: Merge generated data with existing time series
- Domain control: Apply operations in time or frequency domain
- Mode control: Add or multiply generated data
Common parameters for all generators:
shape: Tuple defining (sequence_length, number_of_variates)ts: Existing time series to clone shape fromcombine_domain: "time" or "frequency" domain for combinationcombine_mode: "add" or "mul" for combination operation
Generates Gaussian (normal) distributed noise.
Use case: White noise, natural measurement errors, random fluctuations
Generates uniformly distributed noise where all values within a range are equally likely.
Use case: Random noise with bounded range, testing robustness to uniform perturbations
Generates Laplace (double exponential) distributed noise with heavier tails than normal distribution.
Use case: Noise with occasional large deviations, outlier-prone data
Generates exponentially distributed noise (always positive values).
Use case: Waiting times, inter-arrival times, lifetime data anomalies
Generates gamma distributed noise with flexible shape (always positive values).
Use case: Positive-valued anomalies, skewed distributions, duration modeling
Generates Poisson distributed noise, suitable for count data.
Use case: Count anomalies, event frequency changes, discrete value noise
Generates 1/f^α noise (colored noise) with power spectral density inversely proportional to frequency.
Use case: Natural phenomena noise, long-range correlations, realistic background noise
Note: Uses FFT method to generate frequency-domain colored noise
Generates constant-value anomalies at random locations with configurable length.
Use case: Sensor freezing, stuck values, plateau anomalies
Generates gradual drift/trend patterns over time.
Use case: Sensor degradation, gradual system changes, trend anomalies
Generates sinusoidal patterns with configurable frequency, amplitude, and phase.
Use case: Periodic anomalies, oscillatory patterns, seasonal effects
Generates boolean masks for selective anomaly application.
Use case: Control which time points and variates receive anomalies
Note: Returns boolean mask instead of numeric values
© 2025 G.S.