environmentaltools.temporal.probability_model_fit

environmentaltools.temporal.probability_model_fit(data, tr, method, func, *nyears)[source]

Estimate probability distribution parameters and return period values.

Fits a probability distribution to data using specified method and computes return period values for given return periods.

Parameters:
  • data (array-like) – Time series data (annual maxima or peaks over threshold)

  • tr (array-like) – Return periods in years (e.g., [10, 50, 100, 1000])

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

    Parameter estimation method:

    • ’MLE’: Maximum Likelihood Estimation (uses scipy.stats.fit)

    • ’L-MOM’: L-moments method (custom implementation)

  • func (str or scipy.stats distribution) –

    Probability distribution:

    • For MLE: scipy.stats distribution object

    • For L-MOM: string in [‘expon’, ‘genpareto’, ‘genextreme’, ‘gumbel_r’]

  • *nyears (int, optional) – Number of years in dataset (required for POT analysis with GPD)

Returns:

Array containing [shape, loc, scale, nu, qtr_1, qtr_2, …] where:

  • shape, loc, scale : distribution parameters

  • nu : average number of events per year

  • qtr_i : return level for return period tr[i]

Return type:

np.ndarray

Notes

For annual maxima (GEV, Gumbel): - nu = 1 (one event per year) - Return levels: x_T = F^(-1)(1 - 1/T)

For peaks over threshold (GPD): - nu = n_peaks / n_years - Return levels: x_T = F^(-1)(1 - 1/(T*nu))

L-moments method provides more robust parameter estimates for small samples compared to MLE.

See also

l_mom

L-moments parameter estimation

bootstrapping

Bootstrap resampling for uncertainty estimation

Examples

>>> import scipy.stats as st
>>> data = st.genextreme.rvs(0.1, loc=2, scale=0.5, size=50)
>>> tr = np.array([10, 50, 100])
>>> params = probability_model_fit(data, tr, 'MLE', st.genextreme)
>>> print(f"Shape: {params[0]:.3f}, Loc: {params[1]:.3f}, Scale: {params[2]:.3f}")