dists#
Test statistic distributions models.
Classes:
|
Trials-based representation of a test statistic distribution. |
|
\(\chi^2\)-fit representation of a test statistic distribution. |
|
Histogram-based representation of a test statistic distribution. |
Functions:
|
Convert TS to p-values, interpolating over the background grid. |
- class csky.dists.TSD(values, n_zero=0, **kw)[source]#
Bases:
object
Trials-based representation of a test statistic distribution.
Several methods are in the spirit of scipy.stats distribution objects, but note that at least currently, the interface is not a perfect match.
Methods:
__init__
(values[, n_zero])Construct a Chi2TSD.
sf
(x[, fit])The survival function, similar to
scipy.stats
distributions.sf_nsigma
(x, **kw)The survival function, but returning a value in terms of number of sigmas.
cdf
(x)The cumulative distribution function, similar to
scipy.stats
distributions.isf
(p[, fit])The inverse survival function, similar to
scipy.stats
distributions.median
()The median TS value.
get_hist
(**kw)Get a
histlite.Hist
representation of the distribution.- __init__(values, n_zero=0, **kw)[source]#
Construct a Chi2TSD.
- Parameters:
values (array of float or
utis.Arrays
) – the test statistic valuesn_zero (int) – number of trials not contained by
values
for which TS=0kw (mapping) – additional arguments for
scipy.stats.chi2.fit
. By default, ifloc
andfloc
are not set, thenfloc=0
will be used; ifscale
andfscale
are not set, thenfscale=1
will be used.
- class csky.dists.Chi2TSD(values, n_zero=0, threshold=0, **kw)[source]#
Bases:
TSD
\(\chi^2\)-fit representation of a test statistic distribution.
Information about trials is retained, and a chi2 fit is applied to the region TS > 0.
Methods:
__init__
(values[, n_zero, threshold])Construct a Chi2TSD.
sf
(x[, fit])The survival function, similar to
scipy.stats
distributions.cdf
(x[, fit])The cumulative distribution function, similar to
scipy.stats
distributions.isf
(p[, fit])The inverse survival function, similar to
scipy.stats
distributions.median
([fit])The median TS value.
get_hist
(**kw)Get a
histlite.Hist
representation of the distribution.sf_nsigma
(x, **kw)The survival function, but returning a value in terms of number of sigmas.
Attributes:
The fitted
scipy.stats.chi2
object.- __init__(values, n_zero=0, threshold=0, **kw)[source]#
Construct a Chi2TSD.
- Parameters:
values (array of float or
utis.Arrays
) – the test statistic valuesn_zero (int) – number of trials not contained by
values
for which TS=0kw (mapping) – additional arguments for
scipy.stats.chi2.fit
. By default, ifloc
andfloc
are not set, thenfloc=0
will be used; ifscale
andfscale
are not set, thenfscale=1
will be used.
- property chi2#
The fitted
scipy.stats.chi2
object.
- cdf(x, fit=True)[source]#
The cumulative distribution function, similar to
scipy.stats
distributions.
- get_hist(**kw)#
Get a
histlite.Hist
representation of the distribution.
- sf_nsigma(x, **kw)#
The survival function, but returning a value in terms of number of sigmas.
- class csky.dists.BinnedTSD(values, n_zero=0, **kw)[source]#
Bases:
TSD
Histogram-based representation of a test statistic distribution.
This class tries to reproduce the behavior of
TSD
without storing information about every single trial, thereby reducing RAM and disk space requirements.Methods:
__init__
(values[, n_zero])Construct a Chi2TSD.
median
()The median TS value.
sf
(x[, fit])The survival function, similar to
scipy.stats
distributions.cdf
(x[, fit])The cumulative distribution function, similar to
scipy.stats
distributions.get_hist
(**kw)Get a
histlite.Hist
representation of the distribution.isf
(p[, fit])The inverse survival function, similar to
scipy.stats
distributions.sf_nsigma
(x, **kw)The survival function, but returning a value in terms of number of sigmas.
- __init__(values, n_zero=0, **kw)[source]#
Construct a Chi2TSD.
- Parameters:
values (array of float or
utis.Arrays
) – the test statistic valuesn_zero (int) – number of trials not contained by
values
for which TS=0kw (mapping) – additional arguments for
scipy.stats.chi2.fit
. By default, ifloc
andfloc
are not set, thenfloc=0
will be used; ifscale
andfscale
are not set, thenfscale=1
will be used.
- cdf(x, fit=True)[source]#
The cumulative distribution function, similar to
scipy.stats
distributions.
- get_hist(**kw)#
Get a
histlite.Hist
representation of the distribution.
- sf_nsigma(x, **kw)#
The survival function, but returning a value in terms of number of sigmas.
- csky.dists.ts_to_p(bg, key, ts, fit=True)[source]#
Convert TS to p-values, interpolating over the background grid.
- Parameters:
bg (dict) – the background distributions
key (array of float) – the values that indicate where along the background parameterization each TS value originates from
fit (bool) – whether to request
sf(ts_value, fit=True)