output_analysis.confidence_interval_method()
Determine the minimum number of simulation replications required to achieve
Usage
output_analysis.confidence_interval_method(
replications,
alpha=0.05,
desired_precision=0.1,
min_rep=5,
decimal_places=2
)a target precision in the confidence interval of one or several performance metrics.
This function applies the confidence interval method: it identifies the smallest replication count where the relative half-width of the confidence interval is less than the specified desired_precision for each metric.
Parameters
replications: Union[
pd.Series,
pd.DataFrame,
Sequence[float],
Sequence[Sequence[float]],
Dict[str, Sequence[float]],
]-
Replication results for one or more performance metrics. Accepted formats:
pd.Seriesor 1D list/numpy array → single metricpd.DataFrame→ multiple metrics in columnsdict[str, list/array/Series]→ {metric_name: replications}- list of lists / numpy arrays / Series → multiple metrics unnamed Each inner sequence/Series/numpy array must contain numeric replication results in the order they were generated.
alpha: Optional[float] = 0.05-
Significance level for confidence interval calculations (CI level = 100 * (1 - alpha) %).
desired_precision: Optional[float] = 0.1-
Target CI half-width precision (i.e. percentage deviation of the confidence interval from the mean).
min_rep: Optional[int] = 5-
Minimum number of replications to consider before evaluating precision. Helps avoid unstable early results.
decimal_places: Optional[int] = 2- Number of decimal places to round values in the returned results table.
Returns
- Single-metric input → tuple(n_reps, results_df)- Multi-metric input → dict:-
{metric_name: (n_reps, results_df)} Where- n_reps : int The smallest number of replications achieving the desired precision. Returns -1 if precision is never reached. results_df : pandas.DataFrame Summary statistics at each replication: “Mean”, “Cumulative Mean”, “Standard Deviation”, “Lower Interval”, “Upper Interval”, “% deviation”
Warns
UserWarning- Issued per metric if the desired precision is never reached.