environmentaltools.temporal.confidence_bands
- environmentaltools.temporal.confidence_bands(rmse, n, confidence_level)[source]
Calculate confidence bands for model predictions using RMSE.
Computes confidence intervals around model predictions based on Root Mean Square Error and sample size using Student’s t-distribution.
- Parameters:
rmse (float) – Root Mean Square Error of the model predictions
n (int) – Number of data points used in the model
confidence_level (float) – Confidence level for the interval (e.g., 0.95 for 95% confidence)
- Returns:
Half-width of the confidence band (margin of error)
- Return type:
float
Notes
The confidence band is calculated as:
margin = t_critical * (rmse / sqrt(n))
where t_critical is the critical value from Student’s t-distribution for the specified confidence level and n-1 degrees of freedom.
The prediction interval is then: [prediction - margin, prediction + margin]
Examples
>>> margin = confidence_bands(rmse=0.5, n=100, confidence_level=0.95) >>> # Prediction interval: [y_pred - margin, y_pred + margin]