sparse grid and Sobol index code (Python)
Sparse grid (Smolyak) and Sobol index code written for uncertainty quantification in the course of my research. It is available here under the LGPL in the hope that it will be useful.features
- Arbetrary dimension, tested up to 40 dim
- High-order polynomial integration and interpolation on sparse grids
- Generalized sparse grid fill patterns (following the "index-set" construction of [2])
- Sobol main-effect indices of arbetrary degree. NB: These are based on the sparse-grid surrogate; they will only be as accurate as that is.
- Gauss-Patterson and Clenshaw-Curtis rules (easily extensible for other hierarchical rules by adding a new int_*.py file with the same interface)
The "index-set" construction allows definition of arbetrary sparse-grid
fill-patterns by hand. Automatic adaptivity should be added in due course.
Other freely available sparse-grid implementations:
- SMOLPACK, Knut Petras (C): http://people.sc.fsu.edu/~jburkardt/c_src/smolpack/smolpack.html
- SPARSE_GRID, Jochen Garcke (Python): http://people.sc.fsu.edu/~jburkardt/py_src/sparse_grid/
- SPINTERP, Andreas Klimke (MatLAB): http://www.ians.uni-stuttgart.de/spinterp/
requirements
- Python >=2.6
- numpy >=1.7 (This version is required only for the arbetrary-dimension implentation of meshgrid; if you're working with version 1.6 of numpy, rather than upgrading, you can copy the new meshgrid implementation from the numpy 1.7 source into mylib.py.)
- matplotlib >=1.0 (for plotting only, non-essential)
download
Tar file: smobol.v1.0.tar.gzdocumentation
Only documentation is the inline comments, see especially sparse.py. For example usage see the functions: unittest_integration(), unittest_interpolation(), and unittest_sobol(). For an example of coupling to an external code see "Example: typical use" at the end of sparse.py. The algorithms follow pretty closely those described in the citations below.
Please email me if you find bugs, extend the code in some way, or just find the code useful.
bibliography
- Sergey Smolyak, Quadrature and Interpolation Formulas for Tensor Products of Certain Classes of Functions, Doklady Akademii Nauk SSSR, Volume 4, 1963, pp. 240-243.
- Gerstner and Griebel, Dimension-Adaptive Tensor-Product Quadrature, Computing 71(1), 2003.
- Sobol, I.M. Global sensitivity indices for nonlinear mathematical models and their Monte Carlo estimates. Mathematics and computers in simulation, 55(1-3), 2001, pp. 271-280.
- Tang, G., Eldred, M. and Swiler, L.P. Global sensitivity analysis for stochastic collocation expansion. CSRI Summer Proceeding 2009, 100.
- Alan Genz, A Package for Testing Multiple Integration Subroutines, in Numerical Integration: Recent Developments, Software and Applications, edited by Patrick Keast, Graeme Fairweather, Reidel, 1987, pp. 337-340, ISBN: 9027725144.