aboutsummaryrefslogtreecommitdiff
path: root/utils/dc
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2020-10-05 14:36:40 -0500
committertlatorre <tlatorre@uchicago.edu>2020-10-05 14:36:40 -0500
commitd48484c29d09a944de6f9251a3c659e76279464e (patch)
treec056eaa94e7db434365c285d9a96c0e3659f9d95 /utils/dc
parent1cd79549ee8ceb0f5e64e06611d891098905c05a (diff)
downloadsddm-d48484c29d09a944de6f9251a3c659e76279464e.tar.gz
sddm-d48484c29d09a944de6f9251a3c659e76279464e.tar.bz2
sddm-d48484c29d09a944de6f9251a3c659e76279464e.zip
major updates to the chi2 analysis
This commit fixes the chi2 analysis so that it is no longer biased. Previously, the chi2 analysis pull plots showed a consistent bias. At first, I thought this was due to the fact that the posterior wasn't gaussian, but even after switching to percentile plots based on the algorithm outlined in "Validating Bayesian Inference Algorithms with Simulation-Based Calibration", I was still seeing a bias. I finally tracked it down to the fact that I was applying the energy scale parameters to the data instead of the Monte Carlo. Therefore, in this commit I update the posterior to now apply the energy scale parameters to the Monte Carlo instead of the data. This has the slight disadvantage that the final histograms will be binned in the biased energy, but that's not really a big deal. In addition, this commit contains several other updates: - switch to plotting percentile plots based on the algorithm in "Validating Bayesian Inference Algorithms with Simulation-Based Calibration" instead of pull plots - apply both the energy scale and resolution at the individual particle level, i.e. there is no longer an energy resolution term for electron + muon fits - separate pull plots and coverage plots. Previously I was making both the p-value coverage plots and the pull plots at the same time. However, the pull plots shouldn't have anything to do with the GENIE weights whereas the p-value coverage plots should draw samples weighted by the GENIE weights. In addition, for the pull plots we draw new truth parameters on every iteration whereas for the p-value coverage plots we only draw them once. - switch to using KDEMove() for the MCMC since I think it samples multimodal distributions a lot better than the default emcee move. - I now correct for the reconstruction energy bias in plot-michel and plot-muons
Diffstat (limited to 'utils/dc')
-rwxr-xr-xutils/dc12
1 files changed, 1 insertions, 11 deletions
diff --git a/utils/dc b/utils/dc
index ba363cc..9366b6e 100755
--- a/utils/dc
+++ b/utils/dc
@@ -19,7 +19,6 @@ import numpy as np
from scipy.stats import iqr
import nlopt
from scipy.stats import poisson
-import contextlib
import sys
from math import exp
import emcee
@@ -29,6 +28,7 @@ from matplotlib.lines import Line2D
from sddm.plot import despine
from sddm.dc import *
from sddm.plot_energy import *
+from sddm import printoptions
try:
from emcee import moves
@@ -36,16 +36,6 @@ except ImportError:
print("emcee version 2.2.1 is required",file=sys.stderr)
sys.exit(1)
-# from https://stackoverflow.com/questions/2891790/how-to-pretty-print-a-numpy-array-without-scientific-notation-and-with-given-pre
-@contextlib.contextmanager
-def printoptions(*args, **kwargs):
- original = np.get_printoptions()
- np.set_printoptions(*args, **kwargs)
- try:
- yield
- finally:
- np.set_printoptions(**original)
-
def radius_cut(ev):
ev['radius_cut'] = np.digitize((ev.r/PSUP_RADIUS)**3,(0.9,))
return ev