validphys.closuretest.inconsistent_closuretest package

Submodules

validphys.closuretest.inconsistent_closuretest.inconsistent_ct module

This module contains the InconsistentCommonData class which is meant to have all the methods needed in order to introduce an inconsistency within a Closure Test.

class validphys.closuretest.inconsistent_closuretest.inconsistent_ct.InconsistentCommonData(setname: str, ndata: int, commondataproc: str, nkin: int, nsys: int, commondata_table: DataFrame, systype_table: DataFrame, legacy: bool = False, systematics_table: DataFrame = None, legacy_names: list | None = None, kin_variables: list | None = None)[source]

Bases: CommonData

Class that inherits all of the methods of coredata.CommonData class.

This class is meant to have all the methods needed in order to introduce an inconsistency within a Closure Test.

commondata_table: DataFrame
commondataproc: str
export_uncertainties(buffer)[source]

Same as the export_uncertainties method of the CommonData class. The only difference is that systematic_errors is now a property of the class and not a method.

ndata: int
nkin: int
nsys: int
process_commondata(treatment_names, names_uncertainties, sys_rescaling_factor, inconsistent_datasets)[source]

returns a commondata instance with modified systematics. Note that if commondata.setname is not within the inconsistent_datasets or if both ADD and MULT are False, then the commondata object will not be modified.

Parameters:
  • treatment_names (list) – list of the names of the treatments that should be rescaled possible values are: MULT, ADD

  • names_uncertainties (list) – list of the names of the uncertainties that should be rescaled possible values are: CORR, UNCORR, THEORYCORR, THEORYUNCORR, SPECIAL SPECIAL is used for intra-dataset systematics

  • sys_rescaling_factor (float, int)

  • inconsistent_datasets (list) – list of the datasets for which an inconsistency should be introduced

Return type:

validphys.inconsistent_ct.InconsistentCommonData

rescale_systematics(treatment_names, names_uncertainties, sys_rescaling_factor)[source]

Rescale the columns of the systematic_errors() that are included in the the names_uncertainties list. And return the rescaled table.

Parameters:
  • treatment_names (list) – list of the names of the treatments that should be rescaled possible values are: MULT, ADD

  • names_uncertainties (list) – list of the names of the uncertainties that should be rescaled possible values are: CORR, UNCORR, THEORYCORR, THEORYUNCORR, SPECIAL SPECIAL is used for intra-dataset systematics

  • sys_rescaling_factor (float) – factor by which the systematics should be rescaled

Returns:

self.systematics_table

Return type:

pd.DataFrame

select_systype_table_indices(treatment_names, names_uncertainties)[source]

Is used to get the indices of the systype_table that correspond to the intersection of the treatment_names and names_uncertainties lists.

Parameters:
  • treatment_names (list) – list of the names of the treatments that should be selected possible values are: MULT, ADD

  • names_uncertainties (list) – list of the names of the uncertainties that should be selected possible values are: CORR, UNCORR, THEORYCORR, THEORYUNCORR, SPECIAL SPECIAL is used for intra-dataset systematics

Returns:

systype_tab.index

Return type:

pd.Index

setname: str
property systematic_errors

Overrides the systematic_errors method of the CommonData class.

This is done in order to allow the systematic_errors to be a property and hence to be able to assign values to it (setter).

systematics_table: DataFrame = None
systype_table: DataFrame

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output module

multiclosure_inconsistent_output

Module containing the actions which produce some output in validphys reports i.e figures or tables for (inconsistent) multiclosure estimators in the space of data

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.bootstrapped_table_bias_variance_data(bootstrapped_principal_components_bias_variance_data)[source]

Compute the bias, variance, ratio and sqrt(ratio) for a Datagroup and return a DataFrame with the results. Uncertainty on ratio and sqrt ratio is computed by Gaussian error propagation of the bootstrap uncertainty on bias and variance.

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.bootstrapped_table_bias_variance_datasets(bootstrapped_principal_components_bias_variance_datasets)[source]

Compute the bias, variance, ratio and sqrt(ratio) for each dataset and return a DataFrame with the results. Uncertainty on ratio and sqrt ratio is computed by Gaussian error propagation of the bootstrap uncertainty on bias and variance.

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.delta_histogram(principal_components_normalized_delta_data, title, label_hist=None)[source]

Plot histogram of normalized delta regularized with PCA.

Parameters:
  • principal_components_normalized_delta_data (tuple)

  • title (str) – description of multiclosure

  • label_hist (str) – summary description of multiclosure

Returns:

Figure object

Return type:

fig

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.plot_l2_condition_number(each_dataset, internal_multiclosure_data_collected_loader, evr_min=0.9, evr_max=0.995, evr_n=20)[source]

Plot the L2 condition number of the covariance matrix as a function of the explained variance ratio. The plot gives an idea of the stability of the covariance matrix as a function of the exaplained variance ratio and hence the number of principal components used to reduce the dimensionality.

The ideal explained variance ratio is chosen based on a threshold L2 condition number, in general this threshold number (and the derived explained variance ratio) should be chosen so that

relative error in output (inverse covmat) <= relative error in input (covmat) * condition number Note that in a closure test the relative error in the covariance matrix is very small and only numerical.

Parameters:
  • each_dataset (list) – List of datasets

  • internal_multiclosure_data_loader (list) – list of internal_multiclosure_dataset_loader objects

Yields:

fig – Figure object

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.plot_lambdavalues_bias_variance_values(lambdavalues_bootstrapped_table_bias_variance_datasets, lambdavalues, each_dataset)[source]

Plot sqrt of ratio bias variance as a function of lambda for each dataset.

Parameters:
  • lambdavalues_table_bias_variance_datasets (list) – list of data frames computed as per table_bias_variance_datasets.

  • lambdavalues (list) – list specified in multiclosure_analysis.yaml

  • each_dataset (list) – list of datasets

Yields:

figure

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.plot_lambdavalues_bias_variance_values_full_data(lambdavalues_bootstrapped_table_bias_variance_data, lambdavalues)[source]

Plot sqrt of ratio bias variance as a function of lambda for each dataset.

Parameters:
  • lambdavalues_bootstrapped_table_bias_variance_data (list) – list of data frames computed as per table_bias_variance_data.

  • lambdavalues (list) – list specified in multiclosure_analysis.yaml

Return type:

figure

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.table_bias_variance_data(principal_components_bias_variance_data)[source]

Same as table_bias_variance_datasets but for all the data, meaning that the correlations between the datasets are taken into account.

Parameters:
  • principal_components_bias_variance_data (list) – Same of principal_components_bias_variance_datasets but for all the data

  • each_dataset (list) – List of validphys.core.DataSetSpec

Returns:

DataFrame containing the bias, variance, ratio and sqrt(ratio) for each dataset

Return type:

pd.DataFrame

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.table_bias_variance_datasets(principal_components_bias_variance_datasets, each_dataset)[source]

Compute the bias, variance, ratio and sqrt(ratio) for each dataset and return a DataFrame with the results.

Parameters:
  • principal_components_bias_variance_datasets (list) – List of tuples containing the values of bias, variance and number of degrees of freedom

  • each_dataset (list) – List of validphys.core.DataSetSpec

Returns:

DataFrame containing the bias, variance, ratio and sqrt(ratio) for each dataset

Return type:

pd.DataFrame

validphys.closuretest.inconsistent_closuretest.multiclosure_inconsistent_output.table_xi_indicator_function_data(bootstrapped_indicator_function_data)[source]

Computes the bootstrap average and std of the indicator function for the data.

Parameters:

bootstrapped_indicator_function_data (tuple)

Returns:

DataFrame containing the average and std of the indicator function for the data.

Return type:

pd.DataFrame

Module contents