cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Scipy.py
Go to the documentation of this file.
6
7from scipy import integrate as spint
8import numpy as np
9
10
11def integrate(f, num_dim: int, num_iter: int, num_warmup: int, num_calls: int, limits: list[tuple[float]]=[]):
12 limits = [[lim[0], lim[1]] for lim in (limits if len(limits) > 0 else num_dim * [[0., 1.]])]
13 def f_args(*args):
14 return f(args)
15 return spint.nquad(f_args, limits)
16
17
18if __name__ == '__main__':
19 import math
20 print(integrate(lambda x: x[0]**2 + x[1]**2, 2, 10, 1000, 1000))
21 print(integrate(lambda x: math.sin(x[0]), 1, 10, 1000, 1000, [(0, math.pi)]))