Skip to content

Instantly share code, notes, and snippets.

Alex Pearce alexpearce

Block or report user

Report or block alexpearce

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexpearce
alexpearce / db.py
Created Oct 2, 2018
Snakemake remote file support for a Python dictionary backed by a shelve database.
View db.py
import shelve
import string
import time
class MeasurementDB(object):
r"""Database for storing measurements, with export to LaTeX macros.
Example usage:
@alexpearce
alexpearce / gosu-entrypoint.sh
Created Jul 14, 2017
A entrypoint for a Docker container that can run commands as the user running Docker
View gosu-entrypoint.sh
#!/bin/bash
# Run commands in the Docker container with a particular UID and GID.
# The idea is to run the container like
# docker run -i \
# -v `pwd`:/work \
# -e LOCAL_USER_ID=`id -u $USER` \
# -e LOCAL_GROUP_ID=`id -g $USER` \
# image-name bash
# where the -e flags pass the env vars to the container, which are read by this script.
# By setting copying this script to the container and setting it to the
@alexpearce
alexpearce / bcolz.ipynb
Created Mar 22, 2017
bcolz experiments
View bcolz.ipynb
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 Jan 30, 2017
Lil' notebook.
View nb.ipynb
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 Dec 21, 2016
Ue RooFit PDFs with hep_ml.splot
View splot_with_roofit.py
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
View MultiIndex.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gridsearch.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / histogram_sampling.ipynb
Created Nov 7, 2016
Notebook demonstrating sampling from a histogram PDF with probfit.
View histogram_sampling.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexpearce
alexpearce / RooAsymGaussExp.cxx
Created Jul 7, 2016
The RooAsymGaussExp class, defining a Gaussian PDF with an asymmetric width and exponential tails
View RooAsymGaussExp.cxx
// Asymmetrical Gaussian with exponential tails
// parameters:
// mean - position at maximum
// sigma - sigma of the Gaussian
// asym - asymmetry of the Gaussian ( sigmaLeft = sigma * (1 - asym), sigmaRight = sigma * (1 + asym) )
// rhoL - number of sigmas from mean where left tail starts: mean - rhoL * sigmaLeft
// rhoR - number of sigmas from mean where right tail starts: mean + rhoR * sigmaRight
//
// Allowed values of parameters: sigma > 0, -1 < asym < 1, rhoL > 0, rhoR > 0
@alexpearce
alexpearce / setup_acron_vm.sh
Last active Jun 22, 2016
Set up a CERN OpenStack virtual machine to run acron jobs. See https://alexpearce.me/2016/06/creating-a-vm-for-acron-jobs/ for more.
View setup_acron_vm.sh
#!/bin/sh
echo 'Provisioning acron VM'
# Install what we'll need
sudo yum install -y cern-config-users cern-get-keytab arc-server
# Make sure we ready for Kerberos-authenticated jobs
sudo cern-get-keytab --force
You can’t perform that action at this time.