alpaca.statistics
Classes
- class alpaca.statistics.ChiSquared(sector: Sector, chi2_dict: dict[tuple[str, str], ndarray[float]], dofs_dict: dict[tuple[str, str], ndarray[int]])
- citation_report(filename: str)
Generate a citation report for the measurements in the ChiSquared object.
- constraining_measurements(mode: str = 'y-inverted') ChiSquaredList
Get the constraining measurements for the ChiSquared object.
Parameters
- modestr, optional
- The mode for constraining measurements. Options are:
‘y-inverted’: Selects the measurements that constrain high values of the y-axis.
‘y’: Selects the measurements that constrain low values of the y-axis.
‘grid’: Selects the measurements that constrain each grid point.
Returns
- ChiSquaredList
A list of ChiSquared objects representing the constraining measurements.
- constraining_observables(mode: str = 'y-inverted') ChiSquaredList
Get the constraining observables for the ChiSquared object.
Parameters
- modestr, optional
- The mode for constraining observables. Options are:
‘y-inverted’: Selects the observables that constrain high values of the y-axis.
‘y’: Selects the observables that constrain low values of the y-axis.
‘grid’: Selects the observables that constrain each grid point.
Returns
- ChiSquaredList
A list of ChiSquared objects representing the constraining observables.
- contour(x: ndarray[float], y: ndarray[float], sigma: float = 2.0) tuple[ndarray[float], ndarray[float]]
Generate contour lines for the chi-squared significance.
Parameters
- xnp.ndarray[float]
The x-coordinates of the data points.
- ynp.ndarray[float]
The y-coordinates of the data points.
- sigmafloat, optional
The significance level for the contour (default is 2.0).
Returns
- tuple[np.ndarray[float], np.ndarray[float]]
The x and y coordinates of the contour lines.
- contour_to_csv(x: ndarray[float], y: ndarray[float], filename: str, sigma: float = 2.0, xlabel: str = 'x', ylabel: str = 'y')
Export the contour data to a CSV file.
Parameters
- xnp.ndarray[float]
The x-coordinates of the data points.
- ynp.ndarray[float]
The y-coordinates of the data points.
- filenamestr
The name of the output CSV file.
- sigmafloat, optional
The significance level for the contour (default is 2.0).
- xlabelstr, optional
The label for the x-axis (default is ‘x’).
- ylabelstr, optional
The label for the y-axis (default is ‘y’).
- exclude_measurements(measurements: list[tuple[str, str]]) ChiSquared | None
Exclude specific measurement(s) from the ChiSquared object.
- exclude_observables(observables: list[str]) ChiSquared | None
Exclude specific observable(s) from the ChiSquared object.
- extract_measurements(measurements: list[tuple[str, str]]) ChiSquared
Extract ChiSquared objects for specific measurements from the ChiSquared object.
- extract_observables(observables: list[str]) ChiSquared
Extract ChiSquared objects for specific observable(s) from the ChiSquared object.
- get_inspire_ids() tuple[dict[tuple[str, str], list[str]], dict[str, str]]
Get the Inspire IDs of the measurements in the ChiSquared object.
- get_observables() list[str]
Get a set of all observables from the ChiSquared object.
- set_plot_style(color: str | None = None, lw: float | None = None, ls: str | None = None)
Set the plot style of the sector.
Parameters
- colorstr | None
The color of the sector.
- lwfloat | None
The line width of the sector.
- lsstr | None
The line style of the sector.
- shape() tuple[int, ...]
Get the shape of the chi-squared values.
- slicing(*idx: tuple[slice | int]) ChiSquared
Slice the ChiSquared object along the specified indices.
Parameters
- *idxtuple[slice|int]
The indices to slice the ChiSquared object. At each index, you can specify a slice or an integer. If a slice is provided, it will slice the data along that dimension. If an integer is provided, it will select that specific index along that dimension.
Returns
- ChiSquared
A new ChiSquared object with the sliced data.
- class alpaca.statistics.ChiSquaredList(iterable=(), /)
A list of ChiSquared objects with additional methods for combining and manipulating them.
- citation_report(filename: str)
Generate a citation report for the measurements in the ChiSquared object.
- combine(name: str, tex: str, description: str = '') ChiSquared
Combine the chi-squared values from the list into a single ChiSquared object.
- constraining_measurements(mode: str = 'y-inverted') ChiSquaredList
Get the constraining measurements for the ChiSquaredList.
Parameters
- modestr, optional
- The mode for constraining measurements. Options are:
‘y-inverted’: Selects the measurements that constrain high values of the y-axis.
‘y’: Selects the measurements that constrain low values of the y-axis.
‘grid’: Selects the measurements that constrain each grid point.
Returns
- ChiSquaredList
A list of ChiSquared objects representing the constraining measurements.
- constraining_observables(mode: str = 'y-inverted') ChiSquaredList
Get the constraining observables for the ChiSquaredList.
Parameters
- modestr, optional
- The mode for constraining observables. Options are:
‘y-inverted’: Selects the observables that constrain high values of the y-axis.
‘y’: Selects the observables that constrain low values of the y-axis.
‘grid’: Selects the observables that constrain each grid point.
Returns
- ChiSquaredList
A list of ChiSquared objects representing the constraining observables.
- contains_observable(observable: str) bool
Check if any ChiSquared object in the list contains a specific observable.
- contour(x: ndarray[float], y: ndarray[float], sigma: float = 2.0) tuple[ndarray[float], ndarray[float]]
Generate contour lines for the chi-squared significance across all ChiSquared objects in the list.
Parameters
- xnp.ndarray[float]
The x-coordinates of the data points.
- ynp.ndarray[float]
The y-coordinates of the data points.
- sigmafloat, optional
The significance level for the contour (default is 2.0).
Returns
- tuple[np.ndarray[float], np.ndarray[float]]
The x and y coordinates of the contour lines.
- contour_to_csv(x: ndarray[float], y: ndarray[float], filename: str, sigma: float = 2.0, xlabel: str = 'x', ylabel: str = 'y')
Export the contour data to a CSV file for all ChiSquared objects in the list.
Parameters
- xnp.ndarray[float]
The x-coordinates of the data points.
- ynp.ndarray[float]
The y-coordinates of the data points.
- filenamestr
The name of the output CSV file.
- sigmafloat, optional
The significance level for the contour (default is 2.0).
- xlabelstr, optional
The label for the x-axis (default is ‘x’).
- ylabelstr, optional
The label for the y-axis (default is ‘y’).
- exclude_measurements(measurements: list[tuple[str, str]]) ChiSquaredList | None
Exclude specific measurement(s) from the ChiSquaredList.
- exclude_observables(observables: list[str]) ChiSquaredList | None
Exclude specific observable(s) from the ChiSquaredList.
- extract_measurements(measurements: list[tuple[str, str]]) ChiSquaredList
Extract ChiSquared objects for specific measurement(s) from the list.
- extract_observables(observables: list[str]) ChiSquaredList
Extract ChiSquared objects for a specific observable(s) from the list.
- get_inspire_ids() tuple[dict[tuple[str, str], list[str]], dict[str, str]]
Get the Inspire IDs of the measurements in the ChiSquaredList.
- get_measurements() list[tuple[str, str]]
Get a list of all measurements (observable, experiment) from the ChiSquared objects in the list.
- get_observables() list[str]
Get a set of all observables from the ChiSquared objects in the list.
- significance() ndarray[float]
Calculate the significance for the combined.
- slicing(*idx: tuple[slice | int]) ChiSquaredList
Slice the ChiSquaredList along the specified indices.
Parameters
- *idxtuple[slice|int]
The indices to slice the ChiSquaredList. At each index, you can specify a slice or an integer. If a slice is provided, it will slice the data along that dimension. If an integer is provided, it will select that specific index along that dimension.
Returns
- ChiSquaredList
A new ChiSquaredList with the sliced data.
- split_measurements() ChiSquaredList
Split each ChiSquared object in the list into individual measurements.
- split_observables() ChiSquaredList
Split each ChiSquared object in the list into individual observables.
Functions
- alpaca.statistics.get_chi2(transitions: list[Sector | str | tuple] | Sector | str | tuple, ma: ndarray[float], couplings: ndarray[ALPcouplings], fa: ndarray[float], min_probability: float = 0.0, br_dark=0.0, exclude_projections=True, **kwargs) ChiSquaredList
Calculate the chi-squared values for a set of transitions.
Parameters
- transitions (list[str])
List of transition identifiers.
- manp.ndarray[float]
Mass of the ALP.
- couplingsnp.ndarray[ALPcouplings]
Coupling constants.
- fanp.ndarray[float]
Axion decay constant.
- min_probability (float, optional):
Minimum probability for decay. Default is 0.0. If greater than 0, the processes with an on-shell ALP will only be included if the probability of the ALP decaying in the designated region (prompt, long-lived, etc.) is greater than this value.
- br_dark (float, optional):
Branching ratio for dark sector decays. Default is 0.0.
- exclude_projections (bool, optional):
Whether to exclude projections from measurements. Default is True.
- **kwargs:
Additional keyword arguments passed to chi2_obs.
Returns
- chi2_dictdict[tuple[str, str], np.array]
Dictionary with keys as tuples of transition and experiment identifiers, and values as numpy arrays of chi-squared values. Includes a special key (‘’, ‘Global’) for the combined chi-squared value.