threeML.minimizer package
Submodules
threeML.minimizer.ROOT_minimizer module
threeML.minimizer.grid_minimizer module
- class threeML.minimizer.grid_minimizer.GridMinimizer(function, parameters, verbosity=1)[source]
Bases:
GlobalMinimizer
- add_callback(function)[source]
This adds a callback function which is called after each point in the grid has been used.
- Parameters:
function – a function receiving in input a tuple containing the point in the grid and the minimum of the
function reached starting from that point. The function should return nothing :return: none
- add_parameter_to_grid(parameter, grid)[source]
Add a parameter to the grid
- Parameters:
parameter – an instance of a parameter or a parameter path
grid – a list (or a numpy.array) with the values the parameter is supposed to take during the grid search
- Returns:
None
- valid_setup_keys = ('grid', 'second_minimization', 'callbacks')
threeML.minimizer.minimization module
- exception threeML.minimizer.minimization.BetterMinimumDuringProfiling[source]
Bases:
RuntimeWarning
- class threeML.minimizer.minimization.FunctionWrapper(function, all_parameters, fixed_parameters)[source]
Bases:
object
- class threeML.minimizer.minimization.GlobalMinimization(minimizer_type)[source]
Bases:
_Minimization
- class threeML.minimizer.minimization.GlobalMinimizer(function, parameters, verbosity=1, setup_dict=None)[source]
Bases:
Minimizer
- class threeML.minimizer.minimization.LocalMinimization(minimizer_type)[source]
Bases:
_Minimization
- class threeML.minimizer.minimization.LocalMinimizer(function, parameters, verbosity=1, setup_dict=None)[source]
Bases:
Minimizer
- class threeML.minimizer.minimization.Minimizer(function, parameters, verbosity=1, setup_dict=None)[source]
Bases:
object
- property Npar
- property algorithm_name
- contours(param_1, param_1_minimum, param_1_maximum, param_1_n_steps, param_2=None, param_2_minimum=None, param_2_maximum=None, param_2_n_steps=None, progress=True, **options)[source]
Generate confidence contours for the given parameters by stepping for the given number of steps between the given boundaries. Call it specifying only source_1, param_1, param_1_minimum and param_1_maximum to generate the profile of the likelihood for parameter 1. Specify all parameters to obtain instead a 2d contour of param_1 vs param_2
- Parameters:
param_1 – name of the first parameter
param_1_minimum – lower bound for the range for the first parameter
param_1_maximum – upper bound for the range for the first parameter
param_1_n_steps – number of steps for the first parameter
param_2 – name of the second parameter
param_2_minimum – lower bound for the range for the second parameter
param_2_maximum – upper bound for the range for the second parameter
param_2_n_steps – number of steps for the second parameter
progress – (True or False) whether to display progress or not
log – by default the steps are taken linearly. With this optional parameter you can provide a tuple of
booleans which specify whether the steps are to be taken logarithmically. For example, ‘log=(True,False)’ specify that the steps for the first parameter are to be taken logarithmically, while they are linear for the second parameter. If you are generating the profile for only one parameter, you can specify
‘log=(True,)’ or ‘log=(False,)’ (optional)
- Param:
parallel: whether to use or not parallel computation (default:False)
- Returns:
a : an array corresponding to the steps for the first parameter b : an array corresponding to the steps for the second parameter (or None if stepping only in one direction) contour : a matrix of size param_1_steps x param_2_steps containing the value of the function at the corresponding points in the grid. If param_2_steps is None (only one parameter), then this reduces to an array of size param_1_steps.
- property correlation_matrix
- property covariance_matrix
- property fit_results
- property function
- get_errors()[source]
Compute asymmetric errors using the profile likelihood method (slow, but accurate).
- Returns:
a dictionary with asymmetric errors for each parameter
- minimize(compute_covar=True)[source]
Minimize objective function. This call _minimize, which is implemented by each subclass.
- Parameters:
compute_covar
- Returns:
best fit values (in external reference) and minimum of the objective function
- property parameters
- restore_best_fit()[source]
Reset all the parameters to their best fit value (from the last run fit)
- Returns:
none
- property verbosity
threeML.minimizer.minuit_minimizer module
- class threeML.minimizer.minuit_minimizer.MinuitMinimizer(function, parameters, verbosity=0, setup_dict=None)[source]
Bases:
LocalMinimizer
- get_errors()[source]
Compute asymmetric errors using MINOS (slow, but accurate) and print them.
NOTE: this should be called immediately after the minimize() method
- Returns:
a dictionary containing the asymmetric errors for each parameter.
- valid_setup_keys = ('ftol',)
threeML.minimizer.multinest_minimizer module
threeML.minimizer.pagmo_minimizer module
threeML.minimizer.scipy_minimizer module
- class threeML.minimizer.scipy_minimizer.ScipyMinimizer(function, parameters, verbosity=10, setup_dict=None)[source]
Bases:
LocalMinimizer
- set_algorithm(algorithm: str) None [source]
set the algorithm for the scipy minimizer. Valid entries are “L-BFGS-B”, “TNC”, “SLSQP”
- Parameters:
algorithm (str)
- Returns:
- valid_setup_keys = ('tol', 'algorithm')
threeML.minimizer.tutorial_material module
- class threeML.minimizer.tutorial_material.Complex(**kwargs)[source]
Bases:
Simple
description :
A convex log likelihood with multiple minima
latex : n.a.
parameters :
- k :
desc : normalization initial value : 1.0 fix : yes
mu :
desc : parameter initial value : 5.0 min : 1.0 max : 100
- static info()
- class threeML.minimizer.tutorial_material.CustomLikelihoodLike(name)[source]
Bases:
PluginPrototype
- get_log_like()[source]
Return the value of the log-likelihood with the current values for the parameters
- get_number_of_data_points()[source]
This returns the number of data points that are used to evaluate the likelihood. For binned measurements, this is the number of active bins used in the fit. For unbinned measurements, this would be the number of photons/particles that are evaluated on the likelihood
- inner_fit()
Return the value of the log-likelihood with the current values for the parameters
- class threeML.minimizer.tutorial_material.JointLikelihoodWrap(likelihood_model: Model, data_list: DataList, verbose: bool = False, record: bool = True)[source]
Bases:
JointLikelihood
- fit(*args, **kwargs)[source]
Perform a fit of the current likelihood model on the datasets
- Parameters:
quiet – If True, print the results (default), otherwise do not print anything
:param compute_covariance:If True (default), compute and display the errors and the correlation matrix. :param n_samples: Number of samples to scan the likelihood. :return: a dictionary with the results on the parameters, and the values of the likelihood at the minimum
for each dataset and the total one.
- class threeML.minimizer.tutorial_material.Simple(**kwargs)[source]
Bases:
Function1D
description :
A convex log likelihood
latex : n.a.
parameters :
- k :
desc : normalization initial value : 1.0 fix : yes
mu :
desc : parameter initial value : 5.0 min : 1.0 max : 100
- static info()
- threeML.minimizer.tutorial_material.plot_minimizer_path(jl, points=False)[source]
- Parameters:
jl (JointLikelihood)
- Returns: