Auxiliary Functions¶
-
AuxFunctions.
is_pos_def
(cov, threshold=1e-08)[source]¶ Indicate if a matrix is positive (semi)definite.
- Parameters
cov (nd-array of shape (n_features, n_features)) – Features covariance matrix, where n_features is the number of features.
- Returns
value – True if matrix is positive (semi)definite.
- Return type
- Raises
ValueError when the value cannot be calculated. –
-
AuxFunctions.
correl_matrix
(cov)[source]¶ Generate a correlation matrix from a covariance matrix cov.
- Parameters
cov (nd-array of shape (n_features, n_features)) – Assets covariance matrix, where n_features is the number of features.
- Returns
corr – A correlation matrix.
- Return type
nd-array
- Raises
ValueError when the value cannot be calculated. –
-
AuxFunctions.
cov_fix
(cov, method='clipped', **kwargs)[source]¶ Fix a covariance matrix to a positive definite matrix.
- Parameters
cov (nd-array of shape (n_features, n_features)) – Features covariance matrix, where n_features is the number of features.
method (str) – The default value is ‘clipped’, see more in cov_nearest.
**kwargs –
Other parameters from cov_nearest.
- Returns
cov_ – A positive definite covariance matrix.
- Return type
- Raises
ValueError when the value cannot be calculated. –
-
AuxFunctions.
cov_returns
(cov, seed=0)[source]¶ Generate a matrix of returns that have a covariance matrix cov.
- Parameters
cov (nd-array of shape (n_features, n_features)) – Assets covariance matrix, where n_features is the number of features.
- Returns
a – A matrix of returns that have a covariance matrix cov.
- Return type
nd-array
- Raises
ValueError when the value cannot be calculated. –