axtreme.utils.distibution_helpers¶
Helper for working with scipy distibutions.
Functions
Collects the parameters required for a scipy rv_continous distibution. |
|
|
Fit a distibution, returning the parameters estimate and Gaussian uncertainty of the fit. |
- axtreme.utils.distibution_helpers.distribution_parameter_names_from_scipy(dist: rv_continuous) list[str] ¶
Collects the parameters required for a scipy rv_continous distibution.
Withing axtreme this is used to determine what a GP should predict.
- Parameters:
dist – The distibution to retrieve the parameters for.
- Returns:
The distibutiion parameter names, IN THE ORDER they should be passed to calls to this distibution class. For example:
gumbel_r.pdf(x, loc=0, scale=1) -> order returned [‘loc’,’scale’]
weibull_max.pdf(x, c, loc=0, scale=1) -> order returned [‘c’,’loc’,’scale’]
- axtreme.utils.distibution_helpers.fit_dist_with_uncertainty(data: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], dist: rv_continuous) tuple[ndarray[tuple[int], dtype[float64]], ndarray[tuple[int, int], dtype[float64]]] ¶
Fit a distibution, returning the parameters estimate and Gaussian uncertainty of the fit.
Results of fitting with Maximum Likelihood give a normal distibution where
mean:parameter estimate
covariance matrix: Uncertainty in estimate (Inverse Fischer infomation matrix)
Note
Parameters are returned in tha same order they appear in the fucntion calls of this call. For example, weibull_max.pdf(x, c, loc=0, scale=1) -> order returned [‘c’,’loc’,’scale’] This order can be extracted with the helper function distribution_parameter_names_from_scipy
- Parameters:
data (ArrayLike) – 1 dimensional set of data to fit a distibution to.
dist (rv_continuous) – the distribution to be fitted.
- Returns:
(n) parameter mean estimates covariance: (n,n) covariance matrix of the uncertainty in parameters fitted
- Return type:
feature mean
Todo
Some distributions have convergence issues. Currently only allow gumble_r.
Optimisation method needs thorough testing