From 1257cc23e7532d8dd752cdbd439464370656a52c Mon Sep 17 00:00:00 2001 From: Yannick Ulrich <yannick.ulrich@psi.ch> Date: Sun, 16 Feb 2020 12:13:26 +0100 Subject: [PATCH] 4: prepare quant for writing #12 --- pymule/vegas.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pymule/vegas.py b/pymule/vegas.py index 23b3d63..4c09574 100644 --- a/pymule/vegas.py +++ b/pymule/vegas.py @@ -183,3 +183,33 @@ def exportvegas(dic, filename="", fp=None): nrbins, max(max([len(i) for i in plots]),6) ]) + + quant = np.zeros(2*(nrbins + 2)*nrq) + + minv = [] + maxv = [] + for i in range(len(plots)): + pp = dic[plots[i]].copy() + if len(pp) == 0: + maxv.append(0) ; minv.append(0) + continue + if pp[0,0] != -np.inf: + pp = np.concatenate(([[-np.inf,0,0]], pp)) + if pp[-1,0] != np.inf: + pp = np.concatenate((pp, [[np.inf,0,0]])) + + delta = pp[2,0]-pp[1,0] + maxv.append(pp[1,0] - delta/2 + nrbins * delta) + minv.append(pp[1,0] - delta/2) + + delta = np.array([1] + [delta]*nrbins + [1]) + + quant[i:nrq*(nrbins+2):nrq] = delta * dic['iteration'] * pp[:,1] + + if np.all(pp[:,2] == 0): + quant[nrq*(nrbins + 2) + i::nrq] = \ + quant[i:nrq*(nrbins + 2):nrq]**2/dic['iteration'] + else: + quant[nrq*(nrbins + 2) + i::nrq] = delta**2*dic['iteration']*( + pp[:,2]**2*(dic['iteration']-1) + pp[:,1]**2 + ) -- GitLab