Tools for producing sweights using classic methods or custom orthogonal weight functions (COWs) and for corrected covariance matrices for weighted data fits.
Project description
sweights
pip install sweights
We provide a few tools for projecting component weights ("sweights") for a control variable(s) using a discriminating variable(s). For details please see Dembinski, Kenzie, Langenbruch, Schmelling - arXiv:2112.XXXXX.
We also provide tools for correcting the covariance matrix of fits to weighted data. For details please see Dembinski, Kenzie, Langenbruch, Schmelling - arXiv:2112.XXXXX (Sec IV) and Langenbruch - arXiv:1911.01303.
Documentation
A variety of options for extraction of signal-like weights is provided:
-
classic "sWeights" via the
sweight
class produces pure weight functions and provides the Wkl and Akl matrices- Using the "summation" method from the original sPlot paper Pivk, Le Diberder - arXiv:physics/0402083 referred to as Variant B in arXiv:2112.XXXXX
- Using the "integration" method rederived originally by Schmelling and referred to as Variant A in arXiv:2112.XXXXX
- Using the "refit" method, i.e. taking the covariance matrix of a yield only fit, referred to as Variant Ci in arXiv:2112.XXXXX
- Using the "subhess" method, i.e. taking the sub-covariance matrix for the yields, referred to as Variant Cii in arXiv:2112.XXXXX
- Using the implementation in ROOT's TSPlot (this we believe should be equivalent to Variant B but is more susceptible to numerical differences)
- Using the implementation in RooStat's SPlot (we found this identical to Variant B ("summation") above in all the cases we tried)
-
Custom Orthogonal Weight functions (COWs) via the
cow
class produces pure weight functions and provides Wkl and Akl matrices. It expects- gs - the signal function for the discrimant variable
- gb - the background function(s) for the discriminant variable (can pass orders of polynomials here if desired)
- Im - the variance function for the discriminant variance (can also pass 1 and it will be set of uniform)
- obs - one can instead or additionally pass the observed distribution in the discriminant variable which will be used for the variance function instead. In this case you must pass a two element tuple giving the bin entries and bin edges for the observed dataset (the same as what
np.histogram(data)
would return)
Corrections to the covariance matrix can be implemented using
cov_correct
which computes the full asymptotic correction using Eq. 55 in arXiv:2112.XXXXXapprox_cov_correct
is more straightfoward to compute but only computes the first term in Eq. 55 of arXiv:2112.XXXXX which will be slightly conservative
A test of variable independence based on the Kendall tau coefficient is also provided in kendall_tau
Examples
An example script demonstrating a typical use case is provided in
python tests/examples.py
This does the following:
- Generate toy data in two independent dimensions m and t
-
Fit the toy data in the discriminanting variable to get an estimate of the discriminating variable pdfs
-
Compute sWeights using the "summation" method (implemented by the
sweight
class provided)
- Compute sWeights using the COW method with a variance function of unity, I(m)=1, (implemented by the
cow
class provided)
- Fit the weighted distributions and correct the covariance using the
cov_correct
function provided
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sweights-0.0.3.tar.gz
.
File metadata
- Download URL: sweights-0.0.3.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51cc0ca3a4561573f2fb15d528b3730638d82cafa1c16e4a0175d3cfeff892a5 |
|
MD5 | 0372ce908d522e100a8f7526af2700bc |
|
BLAKE2b-256 | 4266b248e3b92cf8cc425426ff6c90f295027a1777560d9a4732009219db8eee |
File details
Details for the file sweights-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: sweights-0.0.3-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3995ff0f950c427db51a3e68beb3962cab499e9ae932e4d7a1999d6bd3b9fdf |
|
MD5 | 74eaf7cdbe2254a71e82f9ed7ce4ccc1 |
|
BLAKE2b-256 | 95d810de0edd7cb44dfa07bb53cefbe1952eb36029a40da481937235b43c43f5 |