def bootstrap(self,fraction=0.68,niter=100,xmax=None): if xmax is None: nedge = len(self._xedge) else: nedge = len(self._ncounts[self._xedge<=xmax]) xedge = self._xedge[:nedge] h = Histogram.createFromCDF(xedge,self._ncounts[1:nedge]) nbkg = np.random.poisson(self._nbkg,niter).astype(float) ncounts = np.random.poisson(np.concatenate(([0],h.counts)), (niter,nedge)) xq = [] for i in range(niter): x = self._quantile(nbkg[i],self._xedge[:nedge], ncounts[i],fraction) xq.append(x) xq_mean = np.mean(np.array(xq)) xq_rms = np.std(np.array(xq)) return xq_mean, xq_rms
def bootstrap(self,fraction=0.68,niter=100,xmax=None): nedge = len(self._non) hon = Histogram.createFromCDF(self._axis.edges,self._non[1:]) hoff = Histogram.createFromCDF(self._axis.edges,self._noff[1:]) non = np.random.poisson(np.concatenate(([0],hon.counts)), (niter,nedge)) noff = np.random.poisson(np.concatenate(([0],hoff.counts)), (niter,nedge)) xq = [] for i in range(niter): xq.append(self._quantile(non[i],noff[i],fraction)) xq_mean = np.mean(np.array(xq)) xq_rms = np.std(np.array(xq)) return xq_mean, xq_rms