Skip to content

Instantly share code, notes, and snippets.

View alexpearce's full-sized avatar

Alex Pearwin alexpearce

View GitHub Profile
@alexpearce
alexpearce / db.py
Created October 2, 2018 07:31
Snakemake remote file support for a Python dictionary backed by a shelve database.
import shelve
import string
import time
class MeasurementDB(object):
r"""Database for storing measurements, with export to LaTeX macros.
Example usage:
@alexpearce
alexpearce / sweights_example.png
Last active June 24, 2018 03:37
Example of sWeight generation and sWeight distributions in RooFit
sweights_example.png
@alexpearce
alexpearce / binned_chi2.ipynb
Created May 4, 2016 06:53
Notebook to reproduce Alex Rogozhnikov's binned chi^2 demonstration plot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / bcolz.ipynb
Created March 22, 2017 07:36
bcolz experiments
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / nb.ipynb
Last active January 30, 2017 16:54
Lil' notebook.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / splot_with_roofit.py
Created December 21, 2016 13:42
Ue RooFit PDFs with hep_ml.splot
def pdf_probabilities(xs, dependents, yields, pdfs):
"""Return an array of normalised PDF probabilities.
For a list of N yields, each y_i, and a list of N PDFs f_i, the probability
for the ith PDF at the (possibly vector) point x is defined as
p_{i} = \frac{N_{i}f_{i}}{\sum_{i}^{N} N_{i}f_{i}}
Keyword arguments:
xs -- List of values at which to evaluate the PDFs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / triple_gaussian.py
Created September 2, 2015 14:21
Define a triple Gaussian PDF in RooFit
# Name of the delta mass variable in the workspace
dmass_var = 'Dst_delta_M'
# Species of the PDF we're about to build
species = 'sig'
workspace.factory('mu_dm_{0}[141, 146]'.format(species))
workspace.factory('sigma_one_dm_{0}[1, 0, 5]'.format(species))
workspace.factory('nsigma_two_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory('nsigma_three_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory((
'expr::sigma_two_dm_{0}('
@alexpearce
alexpearce / histogram_sampling.ipynb
Created November 7, 2016 14:20
Notebook demonstrating sampling from a histogram PDF with probfit.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.