Parameters¶
-
class
gammapy.utils.fitting.
Parameters
(parameters=None, covariance=None, apply_autoscale=True)[source]¶ Bases:
object
List of
Parameter
.Holds covariance matrix.
Parameters: - parameters : list of
Parameter
List of parameters
- covariance :
ndarray
, optional Parameters covariance matrix. Order of values as specified by
parameters
.- apply_autoscale : bool, optional
Flag for optimizers, if True parameters are autoscaled before the fit, see
autoscale
Attributes Summary
correlation
Correlation matrix ( numpy.ndarray
).free_parameters
List of free parameters names
List of parameter names parameters
List of Parameter
.restore_values
Context manager to restore values. Methods Summary
autoscale
(self[, method])Autoscale all parameters. copy
(self)A deep copy covariance_to_table
(self)Convert covariance matrix to Table
.error
(self, parname)Get parameter error. freeze_all
(self)Freeze all parameters from_dict
(val)set_covariance_factors
(self, matrix)Set covariance from factor covariance matrix. set_error
(self, parname, err)Set parameter error. set_parameter_errors
(self, errors)Set uncorrelated parameters errors. set_parameter_factors
(self, factors)Set factor of all parameters. to_dict
(self)to_table
(self)Convert parameter attributes to Table
.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}} }\]
-
free_parameters
¶ List of free parameters
-
names
¶ List of parameter names
-
restore_values
¶ Context manager to restore values.
A copy of the values is made on enter, and those values are restored on exit.
Examples
from gammapy.spectrum.models import PowerLaw pwl = PowerLaw(index=2) with pwl.parameters.restore_values: pwl.parameters["index"].value = 3 print(pwl.parameters["index"].value)
Methods Documentation
-
autoscale
(self, method='scale10')[source]¶ Autoscale all parameters.
See
autoscale()
Parameters: - method : {‘factor1’, ‘scale10’}
Method to apply
-
error
(self, parname)[source]¶ Get parameter error.
Parameters: - parname : str, int
Parameter name or index
-
set_covariance_factors
(self, matrix)[source]¶ Set covariance from factor covariance matrix.
Used in the optimizer interface.
-
set_error
(self, parname, err)[source]¶ Set parameter error.
Parameters: - parname : str, int
Parameter name or index
- err : float or Quantity
Parameter error
-
set_parameter_errors
(self, errors)[source]¶ Set uncorrelated parameters errors.
Parameters: - errors : dict of
Quantity
Dict of parameter errors.
- errors : dict of
- parameters : list of