Skip to content

Conversation

@Marchma0
Copy link

@Marchma0 Marchma0 commented Dec 2, 2025

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)
  • ReadMe, Docs and GitHub updates

Checklist

  • Tests for the changes have been added (if needed)
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

Currently, the MonteCarlo class allows for running simulations and storing results, but it lacks built-in statistical tools to assess the reliability of these results. There is no native method to calculate confidence intervals, forcing users to manually extract data and perform external calculations to verify simulation convergence (e.g., to ensure the mean apogee has stabilized).

New behavior

This PR implements the estimate_confidence_interval method within the MonteCarlo class, using bootstrapping (via scipy.stats.bootstrap) to calculate confidence intervals for any result attribute (e.g., apogee, max_velocity). This enables users to directly quantify simulation uncertainty and determine if the iteration count is sufficient. Documentation has been updated to explain CI interpretation, and unit tests have been added to validate the calculations.

Breaking change

  • No

Additional information

I haven’t included the documentation yet, and I’m not entirely sure where it should go (in a notebook or a new file). Could you please indicate the appropriate place for it

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.67%. Comparing base (9cf3dd4) to head (73acdf0).
⚠️ Report is 14 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #897      +/-   ##
===========================================
+ Coverage    80.27%   80.67%   +0.39%     
===========================================
  Files          104      107       +3     
  Lines        12769    13301     +532     
===========================================
+ Hits         10250    10730     +480     
- Misses        2519     2571      +52     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks amazing!!!

This is a feature we have always wondered about. So I'm extremely happy to see it being implemented here.

At a first glance, the only thing I would suggest is to update documentation to talk about this methods.

You could extend the docs/user/ pages. This is important so users can easily get to know how to use the new method.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the MonteCarlo class by implementing a bootstrapping-based confidence interval estimation method, enabling users to quantify uncertainty in their simulation results and assess convergence.

Key Changes:

  • Adds estimate_confidence_interval() method to the MonteCarlo class using scipy.stats.bootstrap
  • Implements comprehensive unit tests using a mock MonteCarlo class to validate CI calculations
  • Updates CHANGELOG to document the new feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.

File Description
rocketpy/simulation/monte_carlo.py Adds new public method estimate_confidence_interval() for bootstrapping-based statistical analysis of Monte Carlo results
tests/unit/simulation/test_monte_carlo.py Introduces MockMonteCarlo class and four test functions covering basic CI calculation, custom statistics, error handling, and confidence level consistency
CHANGELOG.md Documents the new bootstrapping feature in the Unreleased section

@Gui-FernandesBR
Copy link
Member

more specifically. Search within the docs/user files and try to see where the MonteCarlo class is being described. You can add a new block of documentation in some already existing file.

@Marchma0
Copy link
Author

Marchma0 commented Dec 2, 2025

Hey, I updated the documentation. Also do you want me to correct the copilot review to ?

@Gui-FernandesBR
Copy link
Member

Hey, I updated the documentation. Also do you want me to correct the copilot review to ?

absolutely! Let me know when all the comments are marked as resolved.

@Gui-FernandesBR Gui-FernandesBR linked an issue Dec 2, 2025 that may be closed by this pull request
4 tasks
Marchma0 and others added 2 commits December 2, 2025 13:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Marchma0
Copy link
Author

Marchma0 commented Dec 2, 2025

I think i resolved or the comments !

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation bot moved this from Backlog to Next Version in LibDev Roadmap Dec 2, 2025
@Gui-FernandesBR Gui-FernandesBR added the Monte Carlo Monte Carlo and related contents label Dec 2, 2025
@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.X.0 milestone Dec 2, 2025
@Gui-FernandesBR Gui-FernandesBR merged commit b252199 into RocketPy-Team:develop Dec 2, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from Next Version to Closed in LibDev Roadmap Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monte Carlo Monte Carlo and related contents

Projects

No open projects
Status: Closed

Development

Successfully merging this pull request may close these issues.

ENH: Implement Bootstrapping for Confidence Interval Estimation

2 participants