madminer.fisherinformation module¶

class
madminer.fisherinformation.
FisherInformation
(filename, include_nuisance_parameters=True)[source]¶ Bases:
madminer.analysis.DataAnalyzer
Functions to calculate expected Fisher information matrices.
After inializing a FisherInformation instance with the filename of a MadMiner file, different information matrices can be calculated:
 FisherInformation.calculate_fisher_information_full_truth() calculates the full truthlevel Fisher information. This is the information in an idealized measurement where all partonlevel particles with their charges, flavours, and fourmomenta can be accessed with perfect accuracy.
 FisherInformation.calculate_fisher_information_full_detector() calculates the full Fisher information in realistic detectorlevel observations, estimated with neural networks. In addition to the MadMiner file, this requires a trained SALLY or SALLINO estimator as well as an unweighted evaluation sample.
 FisherInformation.calculate_fisher_information_rate() calculates the Fisher information in the total cross section.
 FisherInformation.calculate_fisher_information_hist1d() calculates the Fisher information in the histogram of one (partonlevel or detectorlevel) observable.
 FisherInformation.calculate_fisher_information_hist2d() calculates the Fisher information in a twodimensional histogram of two (partonlevel or detectorlevel) observables.
 FisherInformation.histogram_of_fisher_information() calculates the full truthlevel Fisher information in different slices of one observable (the “distribution of the Fisher information”).
Finally, don’t forget that in the presence of nuisance parameters the constraint terms also affect the Fisher information. This term is given by FisherInformation.calculate_fisher_information_nuisance_constraints().
Parameters:  filename : str
Path to MadMiner file (for instance the output of madminer.delphes.DelphesProcessor.save()).
 include_nuisance_parameters : bool, optional
If True, nuisance parameters are taken into account. Default value: True.
Methods
calculate_fisher_information_full_detector
(…)Calculates the full Fisher information in realistic detectorlevel observations, estimated with neural networks. calculate_fisher_information_full_truth
(…)Calculates the full Fisher information at parton / truth level. calculate_fisher_information_hist1d
(self, …)Calculates the Fisher information in the onedimensional histogram of an (partonlevel or detectorlevel, depending on how the observations in the MadMiner file were calculated) observable. calculate_fisher_information_hist2d
(self, …)Calculates the Fisher information in a twodimensional histogram of two (partonlevel or detectorlevel, depending on how the observations in the MadMiner file were calculated) observables. calculate_fisher_information_nuisance_constraints
(self)Builds the Fisher information term representing the Gaussian constraints on the nuisance parameters calculate_fisher_information_rate
(self, …)Calculates the Fisher information in a measurement of the total cross section (without any kinematic information). event_loader
(self[, start, end, batch_size, …])Yields batches of events in the MadMiner file. histogram_of_fisher_information
(self, theta, …)Calculates the full and rateonly Fisher information in slices of one observable. weighted_events
(self[, theta, nu, …])Returns all events together with the benchmark weights (if theta is None) or weights for a given theta. xsec_gradients
(self, thetas[, nus, events, …])Returns the gradient of total cross sections with respect to parameters. xsecs
(self[, thetas, nus, events, …])Returns the total cross sections for benchmarks or parameter points. 
calculate_fisher_information_full_detector
(self, theta, model_file, unweighted_x_sample_file=None, luminosity=300000.0, include_xsec_info=True, mode='score', calculate_covariance=True, batch_size=100000, test_split=0.2)[source]¶ Calculates the full Fisher information in realistic detectorlevel observations, estimated with neural networks. In addition to the MadMiner file, this requires a trained SALLY or SALLINO estimator.
Nuisance parameter are taken into account automatically if the SALLY / SALLINO model was trained with them.
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 model_file : str
Filename of a trained local score regression model that was trained on samples from theta (see madminer.ml.Estimator).
 unweighted_x_sample_file : str or None
Filename of an unweighted x sample that is sampled according to theta and obeys the cuts (see madminer.sampling.SampleAugmenter.extract_samples_train_local()). If None, the Fisher information is instead calculated on the full, weighted samples (the data in the MadMiner file). Default value: None.
 luminosity : float, optional
Luminosity in pb^1. Default value: 300000.
 include_xsec_info : bool, optional
Whether the rate information is included in the returned Fisher information. Default value: True.
 mode : {“score”, “information”}, optional
How the ensemble uncertainty on the kinematic Fisher information is calculated. If mode is “information”, the Fisher information for each estimator is calculated individually and only then are the sample mean and covariance calculated. If mode is “score”, the sample mean is calculated for the score for each event. Default value: “score”.
 calculate_covariance : bool, optional
If True, the covariance between the different estimators is calculated. Default value: True.
 batch_size : int, optional
Batch size. Default value: 100000.
 test_split : float or None, optional
If unweighted_x_sample_file is None, this determines the fraction of weighted events used for evaluation. If None, all events are used (this will probably include events used during training!). Default value: 0.2.
Returns:  fisher_information : ndarray or list of ndarray
Estimated expected full detectorlevel Fisher information matrix with shape (n_parameters, n_parameters). If more then one value ensemble_vote_expectation_weight is given, this is a list with results for all entries in ensemble_vote_expectation_weight.
 fisher_information_uncertainty : ndarray or list of ndarray or None
Covariance matrix of the Fisher information matrix with shape (n_parameters, n_parameters, n_parameters, n_parameters). If more then one value ensemble_vote_expectation_weight is given, this is a list with results for all entries in ensemble_vote_expectation_weight.

calculate_fisher_information_full_truth
(self, theta, luminosity=300000.0, cuts=None, efficiency_functions=None, include_nuisance_parameters=True)[source]¶ Calculates the full Fisher information at parton / truth level. This is the information in an idealized measurement where all partonlevel particles with their charges, flavours, and fourmomenta can be accessed with perfect accuracy, i.e. the latent variables z_parton can be measured directly.
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 luminosity : float
Luminosity in pb^1.
 cuts : None or list of str, optional
Cuts. Each entry is a parseable Python expression that returns a bool (True if the event should pass a cut, False otherwise). Default value: None.
 efficiency_functions : list of str or None
Efficiencies. Each entry is a parseable Python expression that returns a float for the efficiency of one component. Default value: None.
 include_nuisance_parameters : bool, optional
If True, nuisance parameters are taken into account. Default value: True.
Returns:  fisher_information : ndarray
Expected full truthlevel Fisher information matrix with shape (n_parameters, n_parameters).
 fisher_information_uncertainty : ndarray
Covariance matrix of the Fisher information matrix with shape (n_parameters, n_parameters, n_parameters, n_parameters), calculated with plain Gaussian error propagation.

calculate_fisher_information_hist1d
(self, theta, luminosity, observable, bins, histrange=None, cuts=None, efficiency_functions=None, n_events_dynamic_binning=None)[source]¶ Calculates the Fisher information in the onedimensional histogram of an (partonlevel or detectorlevel, depending on how the observations in the MadMiner file were calculated) observable.
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 luminosity : float
Luminosity in pb^1.
 observable : str
Expression for the observable to be histogrammed. The str will be parsed by Python’s eval() function and can use the names of the observables in the MadMiner files.
 bins : int or ndarray
If int: number of bins in the histogram, excluding overflow bins. Otherwise, defines the bin boundaries (excluding overflow bins).
 histrange : tuple of float or None, optional
Minimum and maximum value of the histogram in the form (min, max). Overflow bins are always added. If None and bins is an int, variablewidth bins with equal cross section are constructed automatically. Default value: None.
 cuts : None or list of str, optional
Cuts. Each entry is a parseable Python expression that returns a bool (True if the event should pass a cut, False otherwise). Default value: None.
 efficiency_functions : list of str or None
Efficiencies. Each entry is a parseable Python expression that returns a float for the efficiency of one component. Default value: None.
 n_events_dynamic_binning : int or None, optional
Number of events used to calculate the dynamic binning (if histrange is None). If None, all events are used. Note that these events are not shuffled, so if the events in the MadMiner file are sorted, using a value different from None can cause issues. Default value: None.
Returns:  fisher_information : ndarray
Expected Fisher information in the histogram with shape (n_parameters, n_parameters).
 fisher_information_uncertainty : ndarray
Covariance matrix of the Fisher information matrix with shape (n_parameters, n_parameters, n_parameters, n_parameters), calculated with plain Gaussian error propagation.

calculate_fisher_information_hist2d
(self, theta, luminosity, observable1, bins1, observable2, bins2, histrange1=None, histrange2=None, cuts=None, efficiency_functions=None, n_events_dynamic_binning=None)[source]¶ Calculates the Fisher information in a twodimensional histogram of two (partonlevel or detectorlevel, depending on how the observations in the MadMiner file were calculated) observables.
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 luminosity : float
Luminosity in pb^1.
 observable1 : str
Expression for the first observable to be histogrammed. The str will be parsed by Python’s eval() function and can use the names of the observables in the MadMiner files.
 bins1 : int or ndarray
If int: number of bins along the first axis in the histogram in the histogram, excluding overflow bins. Otherwise, defines the bin boundaries along the first axis in the histogram (excluding overflow bins).
 observable2 : str
Expression for the first observable to be histogrammed. The str will be parsed by Python’s eval() function and can use the names of the observables in the MadMiner files.
 bins2 : int or ndarray
If int: number of bins along the second axis in the histogram in the histogram, excluding overflow bins. Otherwise, defines the bin boundaries along the second axis in the histogram (excluding overflow bins).
 histrange1 : tuple of float or None, optional
Minimum and maximum value of the first axis of the histogram in the form (min, max). Overflow bins are always added. If None, variablewidth bins with equal cross section are constructed automatically. Default value: None.
 histrange2 : tuple of float or None, optional
Minimum and maximum value of the first axis of the histogram in the form (min, max). Overflow bins are always added. If None, variablewidth bins with equal cross section are constructed automatically. Default value: None.
 cuts : None or list of str, optional
Cuts. Each entry is a parseable Python expression that returns a bool (True if the event should pass a cut, False otherwise). Default value: None.
 efficiency_functions : list of str or None
Efficiencies. Each entry is a parseable Python expression that returns a float for the efficiency of one component. Default value: None.
 n_events_dynamic_binning : int or None, optional
Number of events used to calculate the dynamic binning (if histrange is None). If None, all events are used. Note that these events are not shuffled, so if the events in the MadMiner file are sorted, using a value different from None can cause issues. Default value: None.
Returns:  fisher_information : ndarray
Expected Fisher information in the histogram with shape (n_parameters, n_parameters).
 fisher_information_uncertainty : ndarray
Covariance matrix of the Fisher information matrix with shape (n_parameters, n_parameters, n_parameters, n_parameters), calculated with plain Gaussian error propagation.

calculate_fisher_information_nuisance_constraints
(self)[source]¶ Builds the Fisher information term representing the Gaussian constraints on the nuisance parameters

calculate_fisher_information_rate
(self, theta, luminosity, cuts=None, efficiency_functions=None, include_nuisance_parameters=True)[source]¶ Calculates the Fisher information in a measurement of the total cross section (without any kinematic information).
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 luminosity : float
Luminosity in pb^1.
 cuts : None or list of str, optional
Cuts. Each entry is a parseable Python expression that returns a bool (True if the event should pass a cut, False otherwise). Default value: None.
 efficiency_functions : list of str or None
Efficiencies. Each entry is a parseable Python expression that returns a float for the efficiency of one component. Default value: None.
 include_nuisance_parameters : bool, optional
If True, nuisance parameters are taken into account. Default value: True.
Returns:  fisher_information : ndarray
Expected Fisher information in the total cross section with shape (n_parameters, n_parameters).
 fisher_information_uncertainty : ndarray
Covariance matrix of the Fisher information matrix with shape (n_parameters, n_parameters, n_parameters, n_parameters), calculated with plain Gaussian error propagation.

histogram_of_fisher_information
(self, theta, observable, nbins, histrange, model_file=None, luminosity=300000.0, cuts=None, efficiency_functions=None, batch_size=100000, test_split=0.2)[source]¶ Calculates the full and rateonly Fisher information in slices of one observable. For the full information, it will return the truthlevel information if model_file is None, and otherwise the detectorlevel information based on the SALLYtype score estimator saved in model_file.
Parameters:  theta : ndarray
Parameter point theta at which the Fisher information matrix I_ij(theta) is evaluated.
 observable : str
Expression for the observable to be sliced. The str will be parsed by Python’s eval() function and can use the names of the observables in the MadMiner files.
 nbins : int
Number of bins in the slicing, excluding overflow bins.
 histrange : tuple of float
Minimum and maximum value of the slicing in the form (min, max). Overflow bins are always added.
 model_file : str or None, optional
If None, the truthlevel Fisher information is calculated. If str, filename of a trained local score regression model that was trained on samples from theta (see madminer.ml.Estimator). Default value: None.
 luminosity : float, optional
Luminosity in pb^1. Default value: 300000.
 cuts : None or list of str, optional
Cuts. Each entry is a parseable Python expression that returns a bool (True if the event should pass a cut, False otherwise). Default value: None.
 efficiency_functions : list of str or None
Efficiencies. Each entry is a parseable Python expression that returns a float for the efficiency of one component. Default value: None.
 batch_size : int, optional
If model_file is not None: Batch size. Default value: 100000.
 test_split : float or None, optional
If model_file is not None: If unweighted_x_sample_file is None, this determines the fraction of weighted events used for evaluation. If None, all events are used (this will probably include events used during training!). Default value: 0.2.
Returns:  bin_boundaries : ndarray
Observable slice boundaries.
 sigma_bins : ndarray
Cross section in pb in each of the slices.
 fisher_infos_rate : ndarray
Expected rateonly Fisher information for each slice. Has shape (n_slices, n_parameters, n_parameters).
 fisher_infos_full : ndarray
Expected full Fisher information for each slice. Has shape (n_slices, n_parameters, n_parameters).

madminer.fisherinformation.
profile_information
(fisher_information, remaining_components, covariance=None, error_propagation_n_ensemble=1000, error_propagation_factor=0.001)[source]¶ Calculates the profiled Fisher information matrix as defined in Appendix A.4 of arXiv:1612.05261.
Parameters:  fisher_information : ndarray
Original n x n Fisher information.
 remaining_components : list of int
List with m entries, each an int with 0 <= remaining_compoinents[i] < n. Denotes which parameters are kept, and their new order. All other parameters or profiled out.
 covariance : ndarray or None, optional
The covariance matrix of the original Fisher information with shape (n, n, n, n). If None, the error on the profiled information is not calculated. Default value: None.
 error_propagation_n_ensemble : int, optional
If covariance is not None, this sets the number of Fisher information matrices drawn from a normal distribution for the MonteCarlo error propagation. Default value: 1000.
 error_propagation_factor : float, optional
If covariance is not None, this factor multiplies the covariance of the distribution of Fisher information matrices. Smaller factors can avoid problems with illbehaved Fisher information matrices. Default value: 1.e3.
Returns:  profiled_fisher_information : ndarray
Profiled m x m Fisher information, where the ith row or column corresponds to the remaining_components[i]th row or column of fisher_information.
 profiled_fisher_information_covariance : ndarray
Covariance matrix of the profiled Fishere information matrix with shape (m, m, m, m).

madminer.fisherinformation.
project_information
(fisher_information, remaining_components, covariance=None)[source]¶ Calculates projections of a Fisher information matrix, that is, “deletes” the rows and columns corresponding to some parameters not of interest.
Parameters:  fisher_information : ndarray
Original n x n Fisher information.
 remaining_components : list of int
List with m entries, each an int with 0 <= remaining_compoinents[i] < n. Denotes which parameters are kept, and their new order. All other parameters or projected out.
 covariance : ndarray or None, optional
The covariance matrix of the original Fisher information with shape (n, n, n, n). If None, the error on the profiled information is not calculated. Default value: None.
Returns:  projected_fisher_information : ndarray
Projected m x m Fisher information, where the ith row or column corresponds to the remaining_components[i]th row or column of fisher_information.
 profiled_fisher_information_covariance : ndarray
Covariance matrix of the projected Fisher information matrix with shape (m, m, m, m). Only returned if covariance is not None.