flip.fitter#
Attributes#
Classes#
Helper class that provides a standard way to create an ABC using |
|
Class to maximize likelihood with Minuit. |
|
Class to create and run a MCMC sampler with emcee package. |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
Module Contents#
- flip.fitter.log#
- class flip.fitter.BaseFitter(covariance=None, data=None)[source]#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- covariance = None#
- data = None#
- abstract init_from_covariance()[source]#
- The init_from_covariance function is a class method that initializes the
fitter from the covariance matrix. It is here an abstract method that needs to be override
- Parameters:
cls – Pass a class object into a method
- abstract init_from_file()[source]#
- The init_from_covariance function is a class method that initializes the
fitter from the a file containing covariance matrix. It is here an abstract method that needs to be override
- Parameters:
cls – Pass a class object into a method
- get_likelihood(parameter_dict, likelihood_type='multivariate_gaussian', likelihood_properties=None, **kwargs)[source]#
The get_likelihood function is used to create a likelihood object from the covariance matrix. The function takes in a dictionary of parameters, and returns an instance of the likelihood class.
- Parameters:
self – Bind the method to a class
parameter_dict – Pass the parameters to be used in the likelihood function
likelihood_type – Select the likelihood class
:param : Select the likelihood function
- Returns:
A likelihood object
- class flip.fitter.FitMinuit(covariance=None, data=None, likelihood=None, minuit=None)[source]#
Bases:
BaseFitterClass to maximize likelihood with Minuit.
- likelihood = None#
- minuit = None#
- classmethod init_from_covariance(covariance, data, parameter_dict, likelihood_type='multivariate_gaussian', likelihood_properties={}, **kwargs)[source]#
The init_from_covariance function is a class method that initializes the MinuitFitter object. It takes in the covariance matrix, data, parameter dictionary and likelihood type as arguments. The minuit_fitter object is initialized with the covariance matrix and data. The likelihood function is then calculated using get_likelihood() which returns an instance of LikelihoodFunction(). This instance is assigned to minuit_fitter’s attribute ‘likelihood’. The parameter values are extracted from the parameter dictionary and stored in a list called ‘parameter_values’. A Minuit object called ‘minuit’ is
- Parameters:
cls – Create a new instance of the class
covariance – Initialize the covariance matrix of the likelihood
data – Pass the data to the likelihood function
parameter_dict – Pass the parameters to be fitted
likelihood_type – Specify the type of likelihood function to be used
:param : Set the covariance matrix of the data
- Returns:
A minuit_fitter object
- classmethod init_from_file(model_name, model_kind, filename, data, parameter_dict, likelihood_type='multivariate_gaussian', likelihood_properties=None)[source]#
The init_from_file function is a class method that initializes the fitter object from a covariance matrix.
- Parameters:
cls – Pass the class object to the function
model_name – Specify the name of the model
model_kind – Specify the type of model
filename – Load the covariance matrix from a file
data – Initialize the fitter’s data attribute
parameter_dict – Pass in the parameters that are used to
likelihood_type – Specify the type of likelihood function to use
:param : Specify the type of likelihood
- Returns:
A fitter object
- setup_minuit(parameter_dict)[source]#
The setup_minuit function is used to set up the minuit object. It takes a dictionary of parameters as input and sets the errors, fixed values, and limits for each parameter. The error is set to be equal to the value if no error is specified in the dictionary. If a parameter has been fixed then its error will be zero.
- Parameters:
self – Refer to the object itself
parameter_dict – Set the initial values of the parameters
- Returns:
A minuit object
- run(migrad=True, hesse=False, minos=False, n_iter=1)[source]#
The run function is the main function of the class. It takes in a number of arguments, and then runs them through Minuit. The arguments are:
- Parameters:
self – Bind the method to the object
migrad – Run the migrad algorithm
hesse – Run the hesse function
minos – Run the minos function, which is a
:param : Set the number of iterations for migrad
- Returns:
A dictionary with the results of the minimization
- class flip.fitter.FitMCMC(covariance=None, data=None, sampler_name='emcee')[source]#
Bases:
BaseFitterClass to create and run a MCMC sampler with emcee package.
- sampler_name = 'emcee'#
- sampler = None#
- classmethod init_from_covariance(covariance, data, parameter_dict, likelihood_type='multivariate_gaussian', likelihood_properties={}, sampler_name='emcee', nwalkers=1, backend_file=None, **kwargs)[source]#
The init_from_covariance function is a class method that initializes the MCMC fitter from a covariance matrix.
- Parameters:
cls – Create a new instance of the class
covariance – Set the covariance matrix of the multivariate gaussian
data – Calculate the likelihood
parameter_dict – Pass in the parameters of the model
likelihood_type – Specify the type of likelihood function to use
:param : Set the covariance matrix
- Returns:
A mcmc_fitter object
- class flip.fitter.Sampler(likelihood, p0=None)[source]#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- likelihood#
- _p0 = None#
- property ndim#
- property p0#