efficiency¶
analysis_helpers.efficiency
¶
get_sumw2(data, weights, bin_edges)
¶
Calculates the sum of the squared weights in each bin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array
|
data array |
required |
weights
|
array
|
array of weights |
required |
bin_edges
|
array
|
bin edges |
required |
Returns:
| Name | Type | Description |
|---|---|---|
array |
array with the sum of the squared weights in each bin |
Source code in src/analysis_helpers/efficiency.py
weighted_quantile(values, weights, quantiles)
¶
Calculates weighted quantile
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
array
|
Array of values to compute the quantiles for. |
required |
weights
|
array
|
Array of weights corresponding to the values. |
required |
quantiles
|
array
|
Array of quantiles to compute (between 0 and 1). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
array |
Array of computed quantiles. |
Source code in src/analysis_helpers/efficiency.py
weighted_std(values, weights)
¶
Calculates the weighted standard deviation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
array
|
Array of values to compute the standard deviation for. |
required |
weights
|
array
|
Array of weights corresponding to the values. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sum of weights is not positive. |
Returns:
| Name | Type | Description |
|---|---|---|
float |
Weighted standard deviation. |
Source code in src/analysis_helpers/efficiency.py
logq(q, x)
¶
q-logarithm function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
float
|
q parameter |
required |
x
|
float
|
function argument |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
result of the q-logarithm function |
Source code in src/analysis_helpers/efficiency.py
variance_correction(n)
¶
Variance correction function from Eq. 14 of
"Bias, variance, and confidence intervals for efficiency estimators in particle physics experiments", Dembinski et Schmelling (2022) - arXiv:2110.00294<http://arxiv.org/abs/2110.00294>_.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
float
|
effective number of events |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
function to correct the variance |
Source code in src/analysis_helpers/efficiency.py
wilson_interval(p, n, z=1.0)
¶
Wilson interval for a binomial distribution as described in Eq. 42 of
"Bias, variance, and confidence intervals for efficiency estimators in particle physics experiments", Dembinski et Schmelling (2022) - arXiv:2110.00294<http://arxiv.org/abs/2110.00294>_.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
float
|
probability of the binomial distribution |
required |
n
|
float
|
effective number of events |
required |
z
|
float
|
size of the interval in standard deviations of a Normal. Defaults to 1.. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
lower and upper bounds of the interval |
Source code in src/analysis_helpers/efficiency.py
binomial_error(p, n)
¶
Expression of the binomial error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
float
|
probability of the binomial distribution |
required |
n
|
float
|
number of events |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
binomial error |
Source code in src/analysis_helpers/efficiency.py
get_efficiency(passed, total, bin_edges, weights_passed=None, weights_total=None)
¶
Efficiency calculation for a given set of passed and total events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
passed
|
array
|
events that passed the selection |
required |
total
|
array
|
events that are in the total sample |
required |
bin_edges
|
array
|
bin edges |
required |
weights_passed
|
array
|
weights of the events that passed the selection. Defaults to None. |
None
|
weights_total
|
array
|
weights of the events that are in the total sample. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
array with the efficiency and array with the lower and upper bounds of the efficiency |
Source code in src/analysis_helpers/efficiency.py
get_efficiency_array(passed, total, sumw2_total=None)
¶
Efficiency calculation for a given set of passed and total events in a 1d array format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
passed
|
array
|
passed events |
required |
total
|
array
|
total events |
required |
sumw2_total
|
array
|
the sum of squared weights for each bin. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
(array, array)
|
efficiency and confidence level |