Repository navigation
[FEAT] Simulate method for sample trajectories - #1072
Conversation
|
|
|
Thank you for your contribution Ankit Hemant Lade (@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.
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
|
Hey Ankit Hemant Lade (@ankitlade12), thanks for expanding your PR. These are the additional features we were planning to ask for. Saul (@nasaul) will review them, and hopefully they’ll be merged into main in the coming days. Thanks for your patience! |
Saul (nasaul)
left a comment
There was a problem hiding this comment.
This PR is a great contribution for the open source, thanks for this. I've fixed a little of the issues that were raised in the CI/Pytests checks. Some minor things must be addressed before merging:
- Can you add a warning for large simulations?
- Can you add a tutorial demonstrating the new feature?
There are some CI failures still that are not related to this and should be addressed in #1080 so we'll need that merged before this one.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
UCM stored model_["sigma"] but no method (predict, predict_in_sample, forecast) read it; intervals come from statsmodels `forecast.conf_int` directly, and UCM does not implement `simulate()`. The local _calculate_sigma also shadowed statsforecast.utils._calculate_sigma with a different denominator (max(n-1, 1) instead of the convention n - n_params used by the 30+ call sites in models.py). A follow-up can wire UCM into the simulate API from Nixtla#1072 if/when that's planned.
UCM stored model_["sigma"] but no method (predict, predict_in_sample, forecast) read it; intervals come from statsmodels `forecast.conf_int` directly, and UCM does not implement `simulate()`. The local _calculate_sigma also shadowed statsforecast.utils._calculate_sigma with a different denominator (max(n-1, 1) instead of the convention n - n_params used by the 30+ call sites in models.py). A follow-up can wire UCM into the simulate API from Nixtla#1072 if/when that's planned.
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
normal,t(Student's t),bootstrap(empirical),laplace,skew-normal, andged(Generalized Error Distribution).residualsand sigma, enabling non-parametricbootstrapsimulation support.StatsForecast.simulateandGroupedArray.simulateto propagateerror_distributionanderror_paramsthrough the hierarchy.Verification
pytest tests/test_simulation_distributions.py— All 5 tests passed.Checklist
ruffto ensure compliance with the project's style.