Exemple #1
0
 def run_parallel(self):
     f = self.make_integrator()
     res = mp.parmap(f,range(self.nbatches),nprocs=self.nprocs)
     summ, sum2s = zip(*res)
     summ = np.array(summ).sum(axis=0)
     sum2 = np.array(sum2s).sum(axis=0)
     return summ/self.npoints, \
             np.sqrt(sum2-summ**2/self.npoints)/self.npoints
Exemple #2
0
 def run_parallel(self):
     f = self.make_integrator()
     res_sum, var_sum = 0., 0.
     assert len(set(self.batch_sizes))==1
     assert len(self.batch_sizes) == self.nprocs
     res_list = mp.parmap(f,range(self.nbatches),nprocs=self.nprocs)
     for  res, std in res_list:
         res_sum += res
         var_sum += std**2
     return res_sum/self.nbatches,np.sqrt(var_sum)/self.nbatches