environmentaltools.temporal.bootstrapping

environmentaltools.temporal.bootstrapping(peaks, tri, method, func, nyears, nosim, resample)[source]

Perform bootstrap resampling for return period estimation.

Computes distribution parameters and return period values using bootstrap resampling with parametric or non-parametric methods.

Parameters:
  • peaks (array-like) – Annual maxima or peak over threshold time series

  • tri (array-like) – Return periods to evaluate (in years)

  • method ({'MLE', 'L-MOM'}) –

    Fitting method for the probability distribution:

    • ’MLE’: Maximum Likelihood Estimation

    • ’L-MOM’: L-moments method

  • func (str or scipy.stats distribution) – Probability distribution name or object

  • nyears (int) – Number of years in the dataset (for POT analysis)

  • nosim (int) – Number of bootstrap simulations

  • resample ({'parametric', 'non-parametric'}) –

    Resampling method:

    • ’parametric’: Resample from fitted distribution

    • ’non-parametric’: Resample with replacement from original data

Returns:

  • boot (np.ndarray) – Bootstrap results with shape (nosim, n_params + 1 + len(tri)) Contains parameters, nu, and return period values for each simulation

  • orig (np.ndarray) – Original parameter estimates from the data

Notes

Parametric bootstrap: 1. Fit distribution to original data 2. Generate synthetic data from fitted distribution 3. Refit distribution to synthetic data 4. Repeat nosim times

Non-parametric bootstrap: 1. Resample with replacement from original data 2. Fit distribution to resampled data 3. Repeat nosim times

The function handles special cases for GPD and GEV distributions when using L-moments.

Examples

>>> import numpy as np
>>> peaks = np.random.weibull(1.5, 50)
>>> tri = np.array([10, 50, 100])
>>> boot, orig = bootstrapping(
...     peaks, tri, 'L-MOM', 'genextreme', 50, 1000, 'parametric'
... )