Covariance#
- class gammapy.modeling.Covariance(parameters, data=None)[source]#
Bases:
object
Parameter covariance class
- Parameters
- parameters
Parameters
Parameter list
- data
ndarray
Covariance data array
- parameters
Attributes Summary
Correlation matrix (
numpy.ndarray
).Covariance data (
ndarray
)Covariance shape
Methods Summary
from_factor_matrix
(parameters, matrix)Set covariance from factor covariance matrix.
from_stack
(covar_list)Stack sub-covariance matrices from list
get_subcovariance
(parameters)Get sub-covariance matrix
plot_correlation
([ax])Plot correlation matrix.
set_subcovariance
(covar)Set sub-covariance matrix
Attributes Documentation
- correlation#
Correlation matrix (
numpy.ndarray
).Correlation \(C\) is related to covariance \(\Sigma\) via:
\[C_{ij} = \frac{ \Sigma_{ij} }{ \sqrt{\Sigma_{ii} \Sigma_{jj}} }\]
- scipy_mvn#
- shape#
Covariance shape
Methods Documentation
- classmethod from_factor_matrix(parameters, matrix)[source]#
Set covariance from factor covariance matrix.
Used in the optimizer interface.
- classmethod from_stack(covar_list)[source]#
Stack sub-covariance matrices from list
- Parameters
- covar_listlist of
Covariance
List of sub-covariances
- covar_listlist of
- Returns
- covar
Covariance
Stacked covariance
- covar
- get_subcovariance(parameters)[source]#
Get sub-covariance matrix
- Parameters
- parameters
Parameters
Sub list of parameters.
- parameters
- Returns
- covariance
ndarray
Sub-covariance.
- covariance
- plot_correlation(ax=None, **kwargs)[source]#
Plot correlation matrix.
- Parameters
- ax
Axes
, optional Axis to plot on.
- **kwargsdict
Keyword arguments passed to
plot_heatmap
- ax
- Returns
- ax
Axes
, optional Axis
- ax
- set_subcovariance(covar)[source]#
Set sub-covariance matrix
- Parameters
- parameters
Parameters
Sub list of parameters.
- parameters