# CashCountsStatistic#

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

Bases: `gammapy.stats.counts_statistic.CountsStatistic`

Class to compute statistics for Poisson distributed variable with known background.

Parameters
n_onint

Measured counts

mu_bkgfloat

Known level of background

Attributes Summary

 `error` Approximate error from the covariance matrix. `n_bkg` Expected background counts `n_sig` Excess `p_value` Return p_value of measured excess. `sqrt_ts` Return statistical significance of measured excess. `stat_max` Stat value for best fit hypothesis, i.e. expected signal mu = n_on - mu_bkg. `stat_null` Stat value for null hypothesis, i.e. 0 expected signal counts. `ts` Return stat difference (TS) of measured excess versus no excess.

Methods Summary

 `compute_errn`([n_sigma]) Compute downward excess uncertainties. `compute_errp`([n_sigma]) Compute upward excess uncertainties. `compute_upper_limit`([n_sigma]) Compute upper limit on the signal. `n_sig_matching_significance`(significance) Compute excess matching a given significance. `sum`([axis]) Return summed CountsStatistics.

Attributes Documentation

error#

Approximate error from the covariance matrix.

n_bkg#

Expected background counts

n_sig#

Excess

p_value#

Return p_value of measured excess. Here the value accounts only for the positive excess significance (i.e. one-sided).

sqrt_ts#

Return statistical significance of measured excess. The sign of the excess is applied to distinguish positive and negative fluctuations.

stat_max#

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

stat_null#

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

ts#

Return stat difference (TS) of measured excess versus no excess.

Methods Documentation

compute_errn(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(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(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.

n_sig_matching_significance(significance)#

Compute excess matching a given significance.

This function is the inverse of `significance`.

Parameters
significancefloat

Significance

Returns
n_sig`numpy.ndarray`

Excess

sum(axis=None)[source]#

Return summed CountsStatistics.

Parameters
axisNone or int or tuple of ints, optional

Axis or axes on which to perform the summation. Default, axis=None, will perform the sum over the whole array.

Returns
stat`CountsStatistics`

the return stat object