diff --git a/pymule/__init__.py b/pymule/__init__.py index 5489e16dad39edc496c7df19cf3cb4c91c8fa6e3..02eb442485a007b3420770d4f32743b79d08dd21 100644 --- a/pymule/__init__.py +++ b/pymule/__init__.py @@ -18,7 +18,8 @@ __all__ = [ 'addsets', 'scaleset', 'errorband', 'kplot', 'watermark', 'pi', 'alpha', 'GF', 'conv', 'Mmu', 'Mel', 'Mtau', - 'importvegas', 'exportvegas', 'mulify', 'colours' + 'importvegas', 'exportvegas', 'mulify', 'colours', 'printnumber', + 'chisq' ] @@ -29,7 +30,7 @@ from vegas import importvegas, exportvegas from errortools import mergenumbers, plusnumbers, dividenumbers, timesnumbers,\ mergeplots, addplots, divideplots, scaleplot, \ combineplots, combineNplots, \ - integratehistogram, mergebins + integratehistogram, mergebins, printnumber, chisq from loader import importreg, pattern, setup, sigma, \ mergeset, mergeseeds, mergefks, \ addsets, scaleset diff --git a/pymule/errortools.py b/pymule/errortools.py index 4c95b85da654ce0dbad824cb66935b9572c90788..1a529a30a0bf5505b9baee7d3482897441b30cf3 100644 --- a/pymule/errortools.py +++ b/pymule/errortools.py @@ -1,6 +1,17 @@ import numpy as np +def chisq(values): + if type(values) == list: + values = np.array(values) + weight = sum(1 / values[:,1]**2) + value = sum(values[:,0] / values[:,1]**2 / weight) + chi = 1./len(values) * sum( + ((values[:,0]-value) / values[:,1])**2 + ) + return chi + + def mergenumbers(values, quiet=False): if type(values) == list: values = np.array(values) diff --git a/pymule/plot.py b/pymule/plot.py index e424da033a78757c5a252d232b7431f3bfb6b650..6eb02369bd07c377c3cda2bef6efe472e500e360 100644 --- a/pymule/plot.py +++ b/pymule/plot.py @@ -17,6 +17,7 @@ rc('text.latex', preamble="\n".join([ '\\newcommand{\\D}{\\mathrm{d}}' ])) + def setup_pgf(): plt.rcParams.update({ "pgf.texsystem": "pdflatex",