Skip to content

Conversation

@ankitlade12
Copy link

@ankitlade12 ankitlade12 commented Jan 2, 2026

Description

This PR significantly expands the simulate method capabilities across the StatsForecast library. Beyond providing basic sample trajectories, it now supports a wide range of error distributions, enabling high-fidelity probabilistic forecasting and robust scenario analysis.

This implementation centralizes simulation logic, improves model accuracy by incorporating historical residuals, and ensures high consistency across the model library.

Key Changes

  • Advanced Error Distributions:
    • Introduced a centralized statsforecast/simulation.py utility for sampling from multiple distributions: normal, t (Student's t), bootstrap (empirical), laplace, skew-normal, and ged (Generalized Error Distribution).
    • Implemented calibrated variance scaling for all distributions to ensure generated noise matches the model's estimated sigma.
  • Expanded Model Coverage:
    • Smoothing Models: Added simulate methods and analytic prediction intervals to SimpleExponentialSmoothing (Standard & Optimized) and SeasonalExponentialSmoothing (Standard & Optimized).
    • Averaging & Drift Models: Implemented simulate for HistoricAverage, RandomWalkWithDrift, and WindowAverage.
    • Stored Residuals: Updated fit methods across all models to calculate and store residuals and sigma, enabling non-parametric bootstrap simulation support.
  • Improved API & Core Engine:
    • Enhanced StatsForecast.simulate and GroupedArray.simulate to propagate error_distribution and error_params through the hierarchy.
    • Full support for parallel execution (n_jobs) with reproducible seeding for all distributions.

Verification

  • Automated Tests: Added tests/test_simulation_distributions.py covering:
    • High-level StatsForecast API simulations.
    • Individual model-level simulate implementations.
    • Reproducibility across seeds and parallel execution.
    • Bootstrap accuracy using historical residuals.
  • Test Execution: Ran pytest tests/test_simulation_distributions.pyAll 5 tests passed.

Checklist

  • I have followed the Conventional Commits style for commit messages.
  • I have added docstrings following the Google style.
  • I have added tests to cover my changes.
  • I have verified that all tests pass.
  • I have run ruff to ensure compliance with the project's style.

@CLAassistant
Copy link

CLAassistant commented Jan 2, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@MMenchero
Copy link
Contributor

Thank you for your contribution @ankitlade12 We'll currently reviewing it and will get back to you soon.

…cross models

- Added statsforecast/simulation.py for centralized error sampling.
- Updated AutoARIMA, AutoETS, AutoCES, AutoTheta to support multiple error distributions.
- Added simulate() and analytic prediction intervals to SimpleExponentialSmoothing and SeasonalExponentialSmoothing.
- Added simulate() to HistoricAverage, RandomWalkWithDrift, and WindowAverage.
- ensured residuals and sigma are stored after fit() for all models to support bootstrap simulation.
- Cleaned up conversational comments and polished code for production readiness.
- Added comprehensive test suite for multi-distribution simulations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants