Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork231
Open
Labels
Milestone
Description
Is your feature request related to a problem? Please describe.
Currently, the user must guess thenumber_of_simulations (e.g., 1000 or 5000) before running the analysis.
- If the number is too low, the results are statistically insignificant.
- If the number is too high, computational time is wasted.
Users need a way to define atarget precision (e.g., "I want the estimate of the Apogee to be accurate within
Describe the solution you'd like
Implement an automated convergence loop. Instead of specifying a fixed number of simulations, the user specifies atarget variable (e.g., Apogee), aconfidence level, and atolerance width.
TheMonteCarlo class should:
- Run a small batch of simulations.
- Calculate the Confidence Interval (CI) width for the target variable (using the bootstrapping method).
- Check if
CI_width <= tolerance. - If yes, stop. If no, run another batch and repeat.
Implementation Details
- Dependency: This relies on the completion of the "Bootstrapping/CI" issue.
- New Method: Introduce a method like
simulate_until_convergenceor extend the existingsimulatemethod with new arguments. - Batching: To avoid the overhead of recalculating statistics afterevery single flight, simulations should run in chunks (e.g., checking convergence every 50 or 100 flights).
Proposed Usage
analysis=MonteCarlo(...)# "Run simulations until the 95% Confidence Interval# for Apogee is narrower than 20 meters."analysis.simulate_convergence(target_variable="apogee",target_confidence=0.95,tolerance=20.0,# The desired width of the CImin_simulations=100,max_simulations=10000,# Safety stop to prevent infinite loopsbatch_size=50)
Acceptance Criteria
- Implement the convergence loop logic.
- Ensure a safety cap (
max_simulations) prevents infinite loops if convergence is never met. - Allow the user to define the "check frequency" or batch size.
- Log the progress (e.g., "Iteration 500: CI width is 45m... Continuing").
- Add unit tests demonstrating that the simulation stops once the tolerance is reached.
Additional Context
- Performance Note: Calculating the bootstrap CI is computationally expensive. It is crucial that this check is not performed after every single flight, but rather in batches.