Utilities¶
A module that contains miscalleneous methods used in various modules of UQpy
.
-
UQpy.Utilities.
correlation_distortion
(dist_object, rho)[source]¶ This method computes the corelation distortion from Gaussian distribution to any other distribution defined in UQpy.Distributions
Inputs:
- dist_object (
Distribution
object): The object of the Distribution the corelation needs to be calculated.
- dist_object (
- rho (float):
The Gaussian correlation value.
Output/Returns:
- rho_non (float):
The distorted correlation value.
-
UQpy.Utilities.
gradient
(runmodel_object=None, point=None, order='first', df_step=None)[source]¶ This method estimates the gradients (1st, 2nd, mixed) of a function using a finite difference scheme in the standard normal space. First order gradients are calculated using central finite differences.
Inputs:
- runmodel_object (
RunModel
object or a callable ): The numerical model. It should be of type RunModel (see
RunModel
class) or a callable.
- runmodel_object (
- point (ndarray):
The point to evaluate the gradient with shape
point
.shape=(1, dimension)
- order (str):
Order of the gradient. Available options: ‘first’, ‘second’, ‘mixed’.
Default: ‘First’.
- df_step (float):
Finite difference step.
Default: 0.001.
Output/Returns:
- du_dj (ndarray):
Vector of first-order gradients (if order = ‘first’).
- d2u_dj (ndarray):
Vector of second-order gradients (if order = ‘second’).
- d2u_dij (ndarray):
Vector of mixed gradients (if order = ‘mixed’).
-
UQpy.Utilities.
nearest_pd
(input_matrix)[source]¶ This is a method to find the nearest positive-definite matrix to input (1, 2).
Inputs:
- input_matrix (ndarray):
Matrix to find the nearest PD.
Output/Returns:
- pd_matrix (ndarray):
Nearest PD matrix to input_matrix.
-
UQpy.Utilities.
nearest_psd
(input_matrix, iterations=10)[source]¶ A function to compute the nearest positive semi-definite matrix of a given matrix 3.
Inputs:
- input_matrix (ndarray):
Matrix to find the nearest PD.
- iterations (int):
Number of iterations to perform.
Default: 10
Output/Returns:
- psd_matrix (ndarray):
Nearest PSD matrix to input_matrix.
-
UQpy.Utilities.
run_parallel_python
(model_script, model_object_name, sample, dict_kwargs=None)[source]¶ Method needed by
RunModel
to execute a python model in parallel
-
UQpy.Utilities.
svd
(matrix, rank=None, tol=None)[source]¶ Compute the singular value decomposition (SVD) of a matrix.
Inputs:
- matrix (ndarray):
Matrix of
shape=(m, n)
to perform the factorization using thin SVD
- tol (float):
Tolerance to estimate the rank of the matrix.
Default: Machine precision
- iterations (rank):
Number of eigenvalues to keep.
Default: None
Output/Returns:
- u (ndarray):
Matrix of left eigenvectors of
shape=(m, rank)
.
- v (ndarray):
Matrix of right eigenvectors of
shape=(rank, n)
.
- s (ndarray):
Matrix of eigenvalues
shape=(rank, rank)
.
- 1
N.J. Higham, “Computing a nearest symmetric positive semidefinite matrix” (1988), https://doi.org/10.1016/0024-3795(88)90223-6.
- 2
https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd
- 3
Houduo Qi, Defeng Sun, A Quadratically Convergent Newton Method for Computing the Nearest Correlation Matrix, SIAM Journal on Matrix Analysis and Applications 28(2):360-385, 2006.