# CashCountsStatistic¶

class gammapy.stats.CashCountsStatistic(n_on, mu_bkg)[source]

Bases: gammapy.stats.counts_statistic.CountsStatistic

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

Parameters
n_onint

Measured counts

mu_bkgfloat

Expected level of background

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 - mu_bkg

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