WStatCountsStatistic

class gammapy.stats.WStatCountsStatistic(n_on, n_off, alpha)[source]

Bases: gammapy.stats.counts_statistic.CountsStatistic

Class to compute statistics (significance, asymmetric errors , ul) for Poisson distributed variable with unknown background.

Parameters
n_onint

Measured counts in signal (ON) region

n_offint

Measured counts in background only (OFF) region

alphafloat

Acceptance ratio of ON and OFF measurements

Attributes Summary

TS_max

Stat value for best fit hypothesis, i.e.

TS_null

Stat value for null hypothesis, i.e.

background

delta_ts

Return TS difference of measured excess versus no excess.

error

Approximate error from the covariance matrix.

excess

p_value

Return p_value of measured excess.

significance

Return statistical significance of measured excess.

Methods Summary

compute_errn(self[, n_sigma])

Compute downward excess uncertainties.

compute_errp(self[, n_sigma])

Compute upward excess uncertainties.

compute_upper_limit(self[, n_sigma])

Compute upper limit on the signal.

excess_matching_significance(self, significance)

Compute excess matching a given significance.

Attributes Documentation

TS_max

Stat value for best fit hypothesis, i.e. expected signal mu = n_on - alpha * n_off

TS_null

Stat value for null hypothesis, i.e. 0 expected signal counts

background
delta_ts

Return TS difference of measured excess versus no excess.

error

Approximate error from the covariance matrix.

excess
p_value

Return p_value of measured excess.

significance

Return statistical significance of measured excess.

Methods Documentation

compute_errn(self, n_sigma=1.0)

Compute downward excess uncertainties.

Searches the signal value for which the test statistics is n_sigma**2 away from the maximum.

Parameters
n_sigmafloat

Confidence level of the uncertainty expressed in number of sigma. Default is 1.

compute_errp(self, n_sigma=1)

Compute upward excess uncertainties.

Searches the signal value for which the test statistics is n_sigma**2 away from the maximum.

Parameters
n_sigmafloat

Confidence level of the uncertainty expressed in number of sigma. Default is 1.

compute_upper_limit(self, n_sigma=3)

Compute upper limit on the signal.

Searches the signal value for which the test statistics is n_sigma**2 away from the maximum or from 0 if the measured excess is negative.

Parameters
n_sigmafloat

Confidence level of the upper limit expressed in number of sigma. Default is 3.

excess_matching_significance(self, significance)

Compute excess matching a given significance.

This function is the inverse of significance.

Parameters
significancefloat

Significance

Returns
excessnumpy.ndarray

Excess