# [Scipy-tickets] [SciPy] #1573: Proposed n-space integrator for quadpack.py

SciPy Trac scipy-tickets@scipy....
Wed Dec 7 19:05:39 CST 2011

```#1573: Proposed n-space integrator for quadpack.py
-------------------------------------------------------+--------------------
Reporter:  trobinso                                   |       Owner:  somebody
Type:  enhancement                                |      Status:  new
Priority:  low                                        |   Milestone:  0.11.0
Component:  scipy.integrate                            |     Version:  devel
Keywords:  multiple integration, quadpack, integrate  |
-------------------------------------------------------+--------------------
While working with a multivariate information problem for a paper yet to
be defined, I wrote a useful multivariate integrator for n integrations
over n variables. The following is my rough code, as based on ''dblquad''

{{{
def _infuncn(x,func,gfun,hfun,count,epsabs,epsrel,more_args):
a = gfun(x)
b = hfun(x)
myargs = (x,) + more_args
if count == 1:
else:
return

def nquad(func, a, b, args=(), epsabs=1.49e-8, epsrel=1.49e-8, count=2)
''' Recursive, N-depth integrator with number of variables given '''

# Preconditions
if not isinstance( count, int )
raise TypeError('Variable "count" must be an integer value')
if count < 2:
raise ValueError('Variable "count" must be at least 2 to perform \
meaningful multivariate integration. Consider using quad(...)

return
}}}

This form makes several assumptions for simplicity's sake:
1) epsabs and epsrel are the same value for all integrations
2) a and b define static bounds for all integrations
3) In cases where fewer than two integrations are desired, ''quad'' should

It's a simple thing that I'd like to contribute back to the project. I
expect it can be made more robust by your team; in its current form, it
proves quite useful for n-interaction information (that is, n-term mutual
information for every n+1).

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1573>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```