Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CorrelationProvider.py
Go to the documentation of this file.
1"""Python wrapper for parameter and observable correlations."""
2
3from __future__ import annotations
4
5from enum import Enum
6
7from pyhyperiso.core.Common.GeneralEnum import Observables
8from pyhyperiso.core.Common.ParamId import ParamId
9from pyhyperiso.phyperiso.pyhyperiso.core import CorrelationProvider as _CppCorrelationProvider
10
11_CppCorrelationType = _CppCorrelationProvider.CorrelationType
12
13
14class CorrelationType(Enum):
15 """Type of uncertainty correlation to query.
16
17 Attributes:
18 STAT: Statistical-only correlation.
19 SYST: Systematic-only correlation.
20 COMBINED: Correlation after combining statistical and systematic
21 components according to the C++ provider rules.
22 """
23
24 STAT = _CppCorrelationType.STAT
25 SYST = _CppCorrelationType.SYST
26 COMBINED = _CppCorrelationType.COMBINED
27
28
30 """Read correlations stored by the C++ core.
31
32 The provider supports two correlation domains:
33
34 * parameter correlations, addressed with ``ParamId``;
35 * experimental observable correlations, addressed with ``Observables``.
36
37 Examples:
38 >>> corr = CorrelationProvider()
39 >>> corr.correlation_from_observable(
40 ... Observables.BR_B_XS_GAMMA,
41 ... Observables.BR_B_XS_GAMMA,
42 ... CorrelationType.COMBINED,
43 ... )
44 1.0
45 """
46
47 def __init__(self) -> None:
48 """Create a provider bound to the current C++ correlation storage."""
49 self._cpp_obj = _CppCorrelationProvider()
50
52 self,
53 pid_1: ParamId,
54 pid_2: ParamId,
55 corr_type: CorrelationType,
56 ) -> float:
57 """Return the correlation between two parameters.
58
59 Args:
60 pid_1: First parameter identifier.
61 pid_2: Second parameter identifier.
62 corr_type: Statistical, systematic or combined correlation type.
63
64 Returns:
65 Correlation coefficient, typically in ``[-1, 1]``.
66 """
67 return float(self._cpp_obj(pid_1._cpp_obj, pid_2._cpp_obj, corr_type.value))
68
70 self,
71 obs_1: Observables,
72 obs_2: Observables,
73 corr_type: CorrelationType,
74 experiment: str = "DEFAULT",
75 ) -> float:
76 """Return the experimental correlation between two observables.
77
78 Args:
79 obs_1: First observable enum.
80 obs_2: Second observable enum.
81 corr_type: Statistical, systematic or combined correlation type.
82
83 Returns:
84 Correlation coefficient, typically in ``[-1, 1]``.
85 """
86 return float(self._cpp_obj(experiment, obs_1.value, obs_2.value, corr_type.value))
87
88
89__all__ = ["CorrelationProvider", "CorrelationType"]
float correlation_from_paramid(self, ParamId pid_1, ParamId pid_2, CorrelationType corr_type)
float correlation_from_observable(self, Observables obs_1, Observables obs_2, CorrelationType corr_type, str experiment="DEFAULT")