deerlab.UQResult¶
- class UQResult(uqtype, data=None, covmat=None, lb=None, ub=None, threshold=None, profiles=None, noiselvl=None)[source]¶
Represents the uncertainty quantification of fit results.
This class provides methods for performing uncertainty analysis on fit results. The uncertainty analysis can be performed using moment-based, bootstrapped, or likelihood profile methods. The type of uncertainty analysis is specified when initializing the object.
- Attributes:
- typestring
Type of uncertainty analysis performed. Possible values are:
'moment'
- Moment-based uncertainty analysis'bootstrap'
- Bootstrapped uncertainty analysis'profile'
- Likelihood profile uncertainty analysis'void'
- Empty uncertainty analysis
- meanndarray
Mean values of the uncertainty distribution of the parameters.
- medianndarray
Median values of the uncertainty distribution of the parameters.
- stdndarray
Standard deviations of the uncertainty distribution of the parameters.
- covmatndarray
Covariance matrix
- nparamint scalar
Number of parameters in the analysis.
- samplesndarray
Bootstrap samples of the parameters. Only available for
type='bootstrap'
.- profilendarray
Likelihood profile of the parameters. Only available for
type='profile'
.- thresholdscalar
Treshold value used for the profile method. Only available for
type='profile'
.
Methods table¶
|
Initializes the UQResult object. |
|
Compute the confidence intervals for the parameters. |
|
Combine multiple uncertainty quantification instances. |
|
Generate the uncertainty distribution of the n-th parameter |
|
Compute the p-th percentiles of the parameters uncertainty distributions |
|
Uncertainty propagation. |
Methods¶
- UQResult.__init__(uqtype, data=None, covmat=None, lb=None, ub=None, threshold=None, profiles=None, noiselvl=None)[source]¶
Initializes the UQResult object.
- Parameters:
- uqtypestr
Type of uncertainty analysis to perform. Possible values are:
'moment'
,'bootstrap'
,'profile'
,'void'
.- datandarray
Data to be used for the uncertainty analysis. The format of this parameter depends on the value of
uqtype
:If
uqtype='moment'
, data should be an array of parameter estimates.If
uqtype='bootstrap'
, data should be a 2-dimensional array of bootstrap samples, where each row corresponds to a sample and each column corresponds to a parameter.If
uqtype='profile'
, data should be an array of parameter estimates.If
uqtype='void'
, data should not be provided.
- covmatndarray
Covariance matrix of the parameter estimates. Only applicable if
uqtype='moment'
.- lbndarray
Lower bounds of the parameter estimates. Only applicable if
uqtype='moment'
.- ubndarray
Upper bounds of the parameter estimates. Only applicable if
uqtype='moment'
.- thresholdfloat
Threshold value used for the likelihood profile method. Only applicable if
uqtype='profile'
.- profileslist
List of likelihood profiles for each parameter. Each element of the list should be a tuple of arrays
(x, y)
, wherex
represents the values of the parameter andy
represents the corresponding likelihoods. Only applicable ifuqtype='profile'
.- noiselvlfloat
Noise level used for the likelihood profile method. Only applicable if
uqtype='profile'
.
- UQResult.ci(coverage)[source]¶
Compute the confidence intervals for the parameters.
This method computes confidence intervals for the parameters of the fitted distribution, based on the method used to compute the parameter estimates (moment estimation, bootstrapping, or likelihood profile).
- Parameters:
- coveragefloat scalar
Coverage (confidence level) of the confidence intervals (a value between 0-100)
- Returns:
- cindarray
A 2D array containing the lower and upper confidence intervals for the parameters. The first column of the array holds the lower confidence intervals, and the second column holds the upper confidence intervals.
ci[:,0]
- Lower confidence intervalsci[:,1]
- Upper confidence intervals
The array has shape
(nparam, 2)
, wherenparam
is the number of fitted parameters.
- Raises:
- ValueError
If the
coverage
argument is outside the range 0-100.
Notes
The method used to compute the confidence intervals depends on the method used to compute the parameter estimates. If the parameter estimates were computed using moment estimation, the confidence intervals are computed based on the estimated standard errors of the parameters. If the parameter estimates were computed using bootstrapping, the confidence intervals are computed based on the empirical distribution of the bootstrapped samples. If the parameter estimates were computed using likelihood profile, the confidence intervals are computed by finding the parameter values at the edges of the likelihood profile that correspond to the specified coverage.
Examples
Compute 95% confidence intervals for the fitted parameters:
ci = param.ci(95)
- UQResult.join(*args)[source]¶
Combine multiple uncertainty quantification instances.
This method concatenates the parameter vectors of the object calling the method with the parameter vectors of any number of other uncertainty quantification objects.
- Parameters:
- uqany number of deerlab.UQResult
Uncertainty quantification objects with
N1,N2,...,Nn
parameters to be joined to the object calling the method withM
parameters.
- Returns:
- uq_joineddeerlab.UQResult
Joined uncertainty quantification object with a total of
M + N1 + N2 + ... + Nn
parameters. The parameter vectors are concatenated on the order they are passed.
- Raises:
- TypeError
If any of the input objects is not a deerlab.UQResult instance or if the types of the input objects do not match.
- TypeError
If an attempt is made to join an instance of deerlab.UQResult with type
'void'
.
- UQResult.pardist(n=0)[source]¶
Generate the uncertainty distribution of the n-th parameter
This method generates the probability density function of the uncertainty of the n-th parameter of the model. The distribution is evaluated at a range of values where the parameter is most likely to be. The range is determined based on the type of uncertainty quantification method used.
- Parameters:
- nint scalar
Index of the parameter
- Returns:
- axndarray
Parameter values at which the distribution is evaluated
- pdfndarray
Probability density function of the parameter uncertainty.
- UQResult.percentile(p)[source]¶
Compute the p-th percentiles of the parameters uncertainty distributions
- Parameters:
- pfloat scalar
Percentile (a value between 0-100)
- Returns:
- prctilesndarray
Percentile values of all parameters
- Raises:
- ValueError
If is not a number between 0 and 100.
- UQResult.propagate(model, lb=None, ub=None, samples=None)[source]¶
Uncertainty propagation.
The method performs uncertainty propagation on the model by applying the uncertainty analysis of the input parameters to the model. The output is a new uncertainty quantification analysis for the model outputs. The method returns a new
UQResult
object containing the uncertainty information of the model outputs. If the input type is'moment'
, the returned object will be of type'moment'
. Otherwise, if the type is'bootstrap'
, the returned object will be of type'bootstrap'
.- Parameters:
- modelcallable
A callable function that takes an array of parameters as input and returns a model output.
- lbmndarray
Lower bounds of the values returned by
model
, by default assumed unconstrained.- ubmndarray
Upper bounds of the values returned by
model
, by default assumed unconstrained.- samplesint, optional
Number of samples to use when propagating uncertainty. If not provided, default value is 1000.
- Returns:
- modeluqdeerlab.UQResult
New uncertainty quantification analysis for the outputs of
model
.