Skip to main content

Tools for producing sweights using classic methods or custom orthogonal weight functions (COWs) and for correcting 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.04574.

We also provide tools for correcting the covariance matrix of fits to weighted data. For details please see Dembinski, Kenzie, Langenbruch, Schmelling - arXiv:2112.04574 (Sec IV) and Langenbruch - arXiv:1911.01303.

Documentation

The below documentation is now superseeded as it has been moved to readthedocs. Please go to https://sweights.readthedocs.io for the latest.

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

    1. Using the "summation" method from the original sPlot paper Pivk, Le Diberder - arXiv:physics/0402083 referred to as Variant B in arXiv:2112.04574
    2. Using the "integration" method rederived originally by Schmelling and referred to as Variant A in arXiv:2112.04574
    3. Using the "refit" method, i.e. taking the covariance matrix of a yield only fit, referred to as Variant Ci in arXiv:2112.04574
    4. Using the "subhess" method, i.e. taking the sub-covariance matrix for the yields, referred to as Variant Cii in arXiv:2112.04574
    5. Using the implementation in ROOT's TSPlot (this we believe should be equivalent to Variant B but is more susceptible to numerical differences)
    6. 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.04574
  • approx_cov_correct is more straightfoward to compute but only computes the first term in Eq. 55 of arXiv:2112.04574 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

There is also a version written as a .ipynb in doc/tutorial.ipynb

This does the following:

  1. Generate toy data in two independent dimensions m and t

toy

  1. Fit the toy data in the discriminanting variable to get an estimate of the discriminating variable pdfs

  2. Compute sWeights using the "summation" method (implemented by the sweight class provided)

sws

  1. Compute sWeights using the COW method with a variance function of unity, I(m)=1, (implemented by the cow class provided)

cows

  1. Fit the weighted distributions and correct the covariance using the cov_correct function provided

tfit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sweights-0.0.5.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

sweights-0.0.5-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file sweights-0.0.5.tar.gz.

File metadata

  • Download URL: sweights-0.0.5.tar.gz
  • Upload date:
  • Size: 16.5 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

Hashes for sweights-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9851aed28867fd51eb980b3fbc8f3e49bcec101e7ecb76cf03d8c0aba7624691
MD5 a009cb3f9568f381acabeb99fe768783
BLAKE2b-256 569d66416937aa49a538160c91a904c952242dbea7e56c4ad1676bd60cacecb3

See more details on using hashes here.

File details

Details for the file sweights-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sweights-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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

Hashes for sweights-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 42937f0a28dba0c4d5d41ca5c416528a7e512b2833aea726e882cc265e589344
MD5 08125aaf1aeb6543eee91e4eba885ef5
BLAKE2b-256 3e9ef769ac684873d4a0561e85e64ff01e065195ace14f88205257d20befa54f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page