Skip to content

ENH: Implement Bootstrapping for Confidence Interval Estimation #891

@Gui-FernandesBR

Description

@Gui-FernandesBR

Is your feature request related to a problem? Please describe.
Currently, the MonteCarlo class calculates basic statistics (mean and standard deviation) for simulation results. However, users lack a metric to evaluate the reliability of these statistics.

Without confidence intervals, it is difficult to determine if the sample size (number of simulations) is sufficient. Users need a way to quantify the uncertainty of their results (e.g., "We are 95% confident the true mean apogee is between X and Y").

Describe the solution you'd like
Implement a method within the MonteCarlo class that uses Bootstrapping (resampling with replacement) to estimate confidence intervals for simulation outputs.

Implementation Details

  • Target File: rocketpy/simulation/monte_carlo.py
  • Recommended Approach: Use scipy.stats.bootstrap (preferred for robustness) or numpy random choice to resample the data stored in self.results.
  • New Method: Create a method likely named calculate_confidence_interval or estimate_ci.

Proposed Usage

# After running simulations
analysis = MonteCarlo(...)
analysis.simulate(number_of_simulations=500)

# Calculate 95% CI for Apogee
ci_result = analysis.calculate_confidence_interval(
    variable="apogee", 
    confidence_level=0.95, 
    method="BCa" # or 'percentile'
)

print(f"95% CI for Apogee: {ci_result.low} to {ci_result.high}")

Acceptance Criteria

  • Implement a method to calculate Confidence Intervals (CI) for any scalar output variable (e.g., apogee, impact_velocity).
  • Allow the user to specify the confidence level (default to 0.95).
  • Add unit tests to verify the statistical bounds are reasonable.
  • Update documentation with a brief explanation of how to interpret the CI.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request, including adjustments in current codesGood first issueGood for newcomersMonte CarloMonte Carlo and related contents

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions