Benchmarking

Generate tipping and control trajectories, compute indicator trends, and compare them with the area under the ROC curve (AUROC):

AR1 and variance ROC curves for the 100 May harvesting trajectories above.

Example

from tipbox.models import MayHarvesting
from tipbox.datasets import generate_dataset
from tipbox.indicators import rolling_ar1, rolling_variance
from tipbox.metrics import ensemble_roc, plot_roc

# 50 tipping trajectories + 50 controls; retain 300 samples before each reference.
batch = generate_dataset(
    MayHarvesting(), num_tipping=50, num_controls=50, num_samples=1000,
    context_samples=300, noise=1.0, seed=43,
)
signals = batch.observations[:, :, 0]
indicators = {
    "AR1": [rolling_ar1(x, window=100, detrend="linear") for x in signals],
    "Variance": [rolling_variance(x, window=100, detrend="linear") for x in signals],
}
report = ensemble_roc(batch.labels, indicators)  # Labels: 0 control, 1 tipping.
print(report.curves["Variance"].auroc)
ax = plot_roc(report)

num_samples controls the full simulation; context_samples retains 300 observations before each reference. Each trajectory contributes one Kendall trend score. Higher scores indicate tipping.

See the API reference for generation options, event definitions, and missing-score counts.