environmentaltools.temporal.confidence_intervals
- environmentaltools.temporal.confidence_intervals(boot, alpha, resample, *args)[source]
Calculate confidence intervals using percentile or BCa bootstrap methods.
Computes confidence intervals for bootstrap resampling results using either standard percentile method or bias-corrected and accelerated (BCa) method.
- Parameters:
boot (np.ndarray) – Bootstrap resampling matrix with shape (n_simulations, n_parameters)
alpha (float) – Significance level (e.g., 0.05 for 95% confidence intervals)
resample ({'standard', 'bca'}) –
Method for estimating confidence intervals:
’standard’: Simple percentile method
’bca’: Bias-corrected and accelerated bootstrap
*args (tuple, optional) –
Additional arguments required for BCa method: (orig, nosim, peaks, tri, tipo, nyears) where:
- origarray-like
Original parameter estimates
- nosimint
Number of bootstrap simulations
- peaksarray-like
Original peak time series
- triarray-like
Return periods
- tipostr or scipy.stats distribution
Distribution type
- nyearsint
Number of years in the dataset
- Returns:
Confidence interval bounds with shape (2, n_parameters):
ci[0, :] : lower bounds
ci[1, :] : upper bounds
- Return type:
np.ndarray
Notes
The BCa method adjusts for bias and skewness in the bootstrap distribution using acceleration (a) and bias-correction (z0) factors. It provides more accurate intervals than standard percentiles, especially for small samples or skewed distributions.
The acceleration factor is computed using jackknife influence values: a = sum(U^3) / [6 * sum(U^2)^(3/2)]
where U are the jackknife deviations.
References
Efron, B. (1987). “Better Bootstrap Confidence Intervals”. Journal of the American Statistical Association, 82(397), 171-185.
Examples
>>> boot = np.random.randn(1000, 3) # Bootstrap samples >>> ci = confidence_intervals(boot, alpha=0.05, resample='standard') >>> print(f"95% CI: [{ci[0, 0]:.3f}, {ci[1, 0]:.3f}]")