We provide a tool to calculate signal weights called sWeights, which can be used to project out the signal component in a mixture of signal and background in a control variable(s), while using fits in an independent discriminating variable. This technique was first popularized under the name sPlot method, but we think this is a misnomer and hence call it sWeights, since it is useful for more than plotting. We found that sWeights are a special case of more general Custom Orthogonal Weight functions (COWs), which extend the range of applicability of classic sWeights. If you use this package, please cite our paper:
If you cannot access this paper for free, checkout the preprint arXiv:2112.04574.
We also provide tools for computing the correct covariance matrix of fits to weighted data, described in section IV of our paper and in more detail in Langenbruch arXiv:1911.01303. The standard method of inverting the Hesse matrix does not work. When in doubt, please use the bootstrap method.
Installation
You can install sweights from PyPI.
pip install sweights
Documentation
You can find our documentation here, which contain tutorials how to use the package and how avoid pitfalls.
Partner projects
numba_stats provides faster implementations of probability density functions than scipy, and a few specific ones used in particle physics that are not in scipy.
boost-histogram from Scikit-HEP provides fast generalized histograms that you can use with the builtin cost functions.
jacobi provides a robust, fast, and accurate calculation of the Jacobi matrix of any transformation function and building a function for generic error propagation.
resample provides a simple API to calculate bootstrap estimate.
Release files for sweights 1.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sweights-1.7.0.tar.gz | 1.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sweights-1.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.5 MB
Release files / sweights-1.7.0.tar.gz
| Download URL | sweights-1.7.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28ed06b865253c2d86b3897681aeb025a7df6c8f09d8ef48667297dd936e9db7
|
|
BLAKE2b-256 checksum How to use checksums |
b327bde1f84d67d004a027fcdd37799342eb8cf5faa32f8928851686e412267b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 19, 2025.
Transparency logRelease files / sweights-1.7.0-py3-none-any.whl
| Download URL | sweights-1.7.0-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
844525241011a15f00aeff20a844e80c7c3e2d1f4ae0e73650e1220d52d696f2
|
|
BLAKE2b-256 checksum How to use checksums |
b0db26600958946918275e19ebfc15f9161e4d5b1e31372fc1b7e5c6abb06f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 19, 2025.
Transparency log