arxiv:hep-ph/ v1 2 Sep 2005

Similar documents
Package R2Cuba. October 2, 2015

Applications of MPI I

An Adaptive Importance Sampling Technique

Monte Carlo integration

Cuba.jl Documentation

VARIANCE REDUCTION TECHNIQUES IN MONTE CARLO SIMULATIONS K. Ming Leung

arxiv: v1 [physics.comp-ph] 27 Aug 2014

Computer Experiments. Designs

A Memory-Efficient Algorithm for Adaptive Multidimensional Integration with Multiple GPUs

Monte Carlo Integration and Random Numbers

Accuracy estimation for quasi-monte Carlo simulations

PAMIHR. A Parallel FORTRAN Program for Multidimensional Quadrature on Distributed Memory Architectures

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. - Statistical Methods -

Elemental Set Methods. David Banks Duke University

A Random Number Based Method for Monte Carlo Integration

Chapter 1. Introduction

6 Distributed data management I Hashing

MATH3016: OPTIMIZATION

Testing unrolling optimization technique for quasi random numbers

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10

An Evolutionary Algorithm for Minimizing Multimodal Functions

Halftoning and quasi-monte Carlo

Computational Methods. Randomness and Monte Carlo Methods

Interleaving Schemes on Circulant Graphs with Two Offsets

arxiv: v1 [hep-ph] 8 Nov 2007

Integration. Volume Estimation

Simple shooting-projection method for numerical solution of two-point Boundary Value Problems

A noninformative Bayesian approach to small area estimation

7.7 Quasi- (that is, Sub-) Random Sequences

Fast Generation of Nested Space-filling Latin Hypercube Sample Designs. Keith Dalbey, PhD

Truss structural configuration optimization using the linear extended interior penalty function method

A nodal based evolutionary structural optimisation algorithm

Cubature Rules for High-dimensional Adaptive Integration

Computational Geometry

Randomized algorithms have several advantages over deterministic ones. We discuss them here:

= f (a, b) + (hf x + kf y ) (a,b) +

For the hardest CMO tranche, generalized Faure achieves accuracy 10 ;2 with 170 points, while modied Sobol uses 600 points. On the other hand, the Mon

Chapter 2 Modeling Distributions of Data

DEDICATIONS. To my dear parents, and sisters. To my advisor Dr. Mahmoud Alrefaei. To my friends in and out the university.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

MONTE CARLO EVALUATION OF DEFINITE INTEGRALS

1.1 THIS IS LINES 1.2 FUNCTIONS

SIMULATED ANNEALING TECHNIQUES AND OVERVIEW. Daniel Kitchener Young Scholars Program Florida State University Tallahassee, Florida, USA

A Superconvergent Monte Carlo Method for Multiple Integrals on the Grid

THE NUMBER OF LINEARLY INDUCIBLE ORDERINGS OF POINTS IN d-space* THOMAS M. COVERt

What Secret the Bisection Method Hides? by Namir Clement Shammas

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving

Implementation of the Pseudo-Random Numbers Generators and the Low Discrepancy Sequences

STA Rev. F Learning Objectives. Learning Objectives (Cont.) Module 3 Descriptive Measures

Load Balancing for Problems with Good Bisectors, and Applications in Finite Element Simulations

Supersedes: S-S-01. (a) acceptance sampling of discrete units presented for inspection in lots;

An introduction to design of computer experiments

Lecture 2 September 3

APPM/MATH Problem Set 4 Solutions

10.4 Measures of Central Tendency and Variation

10.4 Measures of Central Tendency and Variation

The New Bisection Plus Algorithm by Namir Shammas

Edge and local feature detection - 2. Importance of edge detection in computer vision

Chapter 2: The Normal Distributions

WHOLE NUMBER AND DECIMAL OPERATIONS

Extending partial projective planes

Methods and Models for Combinatorial Optimization Exact methods for the Traveling Salesman Problem

Clustering and Visualisation of Data

Linear Congruential Number Generators. A useful, if not important, ability of modern computers is random number

A MORPHOLOGY-BASED FILTER STRUCTURE FOR EDGE-ENHANCING SMOOTHING

Probabilistic (Randomized) algorithms

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. Lecture 14

1 The range query problem

Homework 4: Clustering, Recommenders, Dim. Reduction, ML and Graph Mining (due November 19 th, 2014, 2:30pm, in class hard-copy please)

Line Arrangement. Chapter 6

Estimation of Item Response Models

D01FCF NAG Fortran Library Routine Document

form are graphed in Cartesian coordinates, and are graphed in Cartesian coordinates.

CHAPTER 4. Numerical Models. descriptions of the boundary conditions, element types, validation, and the force

Random Numbers and Monte Carlo Methods

Interactive Math Glossary Terms and Definitions

CHAPTER 2 Modeling Distributions of Data

Geometry. Every Simplicial Polytope with at Most d + 4 Vertices Is a Quotient of a Neighborly Polytope. U. H. Kortenkamp. 1.

Ranking Clustered Data with Pairwise Comparisons

Extending partial projective planes

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. - Statistics and Error Analysis -

Three applications of Euler s formula. Chapter 10

Automatic CFD Optimizing of Hull Forms Using Strategy-Driven Transformation Functions

The Grid File: An Adaptable, Symmetric Multikey File Structure

A GENTLE INTRODUCTION TO THE BASIC CONCEPTS OF SHAPE SPACE AND SHAPE STATISTICS

A Short SVM (Support Vector Machine) Tutorial

Reliable Adaptive Algorithms for Integration, Interpolation and Optimization

9.1 Bracketing and Bisection

4. Feedforward neural networks. 4.1 Feedforward neural network structure

Multivariate Data Analysis and Machine Learning in High Energy Physics (V)

Cluster Analysis. Mu-Chun Su. Department of Computer Science and Information Engineering National Central University 2003/3/11 1

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Black generation using lightness scaling

NUMERICAL METHODS PERFORMANCE OPTIMIZATION IN ELECTROLYTES PROPERTIES MODELING

Outline. Advanced Digital Image Processing and Others. Importance of Segmentation (Cont.) Importance of Segmentation

Data Partitioning. Figure 1-31: Communication Topologies. Regular Partitions

Introduction to Optimization Problems and Methods

15. Cutting plane and ellipsoid methods

Fully discrete Finite Element Approximations of Semilinear Parabolic Equations in a Nonconvex Polygon

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Transcription:

arxiv:hep-ph/0509016v1 2 Sep 2005 The Cuba Library T. Hahn Max-Planck-Institut für Physik Föhringer Ring 6, D 80805 Munich, Germany Concepts and implementation of the Cuba library for multidimensional numerical integration are elucidated. 1. Overview Cuba [1] is a library for multidimensional numerical integration. It features four integration algorithms with interfaces for Fortran, C/C++, and Mathematica. All four can integrate vector integrands and their invocation is quite similar to make it easy to switch routines for comparison. The main characteristics are summarized below. Routine: Vegas Basic integration methods available: Sobol sample (quasi Monte Carlo) Mersenne Twister sample (pseudo Monte Carlo) Variance reduction: importance sampling Routine: Suave Basic integration methods available: Sobol sample (quasi Monte Carlo) Mersenne Twister sample (pseudo Monte Carlo) Variance reduction: importance sampling combined with globally adaptive subdivision Routine: Divonne Basic integration methods available: Korobov sample (lattice method) Sobol sample (quasi Monte Carlo) Mersenne Twister sample (pseudo Monte Carlo) cubature rules (deterministic method) Variance reduction: stratified sampling, aided by methods from numerical optimization Routine: Cuhre Basic integration method available: cubature rules (deterministic method) Variance reduction: globally adaptive subdivision Before explaining the buzzwords appearing in this list, it is perhaps worthwhile to address two frequently asked questions. First, numerical integration rapidly becomes more difficult with increasing dimension, no matter how many tricks are built into the integrator. To illustrate this, imagine computing the volume of the d-dim. sphere S d by integrating its characteristic function χ = θ(1 x 2 ) inside the surrounding hypercube C d = [ 1, 1] d. In a Monte Carlo way of thinking, then, the ratio r = Vol S d / VolC d can be taken as the chance that a general-purpose integrator will find the sphere at all. The numbers clearly display what is often termed the curse of dimensionality : d 2 5 10 50 r.785.164.0025 1.5 10 28 (1) Second, Cuba (and, for that matter, most multidimensional integrators) can do only Riemann integrals of the form If := 0 d d xf( x). (2) Most questions concern the boundaries, although it is straightforward to transform a finite integration region to the unit hypercube: b1 bd d a 1 xf( x) = a d 0 d d y J f( x), (3) d J = (b i a i ), x i = a i + (b i a i )y i. i=1 2. Concepts 2.1. Deterministic vs. Monte Carlo Cuba contains both deterministic and Monte Carlo integration methods. The deterministic ap- 1

2 T. Hahn Max-Planck-Institut für Physik Föhringer Ring 6, D 80805 Munich, Germany proach is based on cubature rules, If C n f := n w i f( x i ) (4) i=1 with specially chosen nodes x i and weights w i. Error estimation is done e.g. by null rules N m (m < n) which are constructed to give zero for functions integrated exactly by C n and thus measure errors due to higher terms. The Monte Carlo estimate, although quite similar in form, If M n f := 1 n n f( x i ), (5) i=1 is conceptually very different as this formula denotes the statistical average over independent and identically distributed random samples x i. In this case the standard deviation furnishes a probabilistic estimate of the integration error: σ(m n f) = M n f 2 M 2 nf. (6) 2.2. Construction of Cubature Rules Starting from an orthogonal basis of functions {b 1,...,b m } usually monomials with which most f can (hopefully) be approximated sufficiently well one imposes that each b i be integrated! exactly by C n : Ib i =C n b i. These are m moment equations n w k b i ( x k ) = k=1 0 d d xb i ( x) (7) for nd + n unknowns x i and w i. They pose a formidable, in general nonlinear, system of equations. Additional assumptions, e.g. symmetries, are usually necessary to solve this system. Cuba employs the Genz Malik rules [2] constructed from a symmetric monomial basis. 2.3. Globally Adaptive Subdivision Once an error estimate for the integral is available, global adaptiveness is easy to implement: 1. Integrate the entire region: I tot ± E tot. 2. while E tot > max(ε rel I tot, ε abs ) 3. Find the region r with the largest error. 4. Bisect (or otherwise cut up) r. 5. Integrate each subregion of r separately. 6. I tot = I i, E tot = E 2 i. 7. end while A remark is in order here about the two precisions, ε rel and ε abs. Naively what one imposes is the relative precision: the result is supposed to be accurate to, say, one part in a thousand, i.e. ε rel = 10 3. For integral values approaching zero, however, this goal becomes harder and harder to reach, and so as not to spend inordinate amounts of time in such cases, an absolute precision ε abs can be prescribed, where typically ε abs ε rel. 2.4. Importance Sampling Importance sampling introduces a weight function into the integral: If = 0 d d xw( x) f( x) w( x), (8) w( x) > 0, Iw = 1, with two requirements: a) one must be able to sample from the distribution w( x), b) f/w should be smooth in the sense that σ w (f/w) < σ(f), e.g. w and f should have the same peak structure. The ideal choice is known to be w( x) = f( x) /If which has σ w (f/w) = 0, but is of little use as it requires a-priori knowledge of the integral value. 2.5. Stratified Sampling Stratified sampling works by sampling subregions. Consider a total of n points sampled in a region r = r a + r b vs. n/2 points sampled in r a and n/2 in r b. In the latter case the variance is ( 1 σ 2 a f 4 n/2 + σ2 b f ) = σ2 af + σb 2f n/2 2n whereas in the former case it can be written as (9) σ 2 f n = σ2 af + σb 2f + (I af I b f) 2. (10) 2n 4n Even in this simple example the latter variance is at best equal to the former one, and only if the integral values are identical. The optimal reduction of variance can be shown to occur for

3 The Cuba Library na /nb = σa f /σb f [3]. The recipe is thus to split up the integration region into parts with equal variance, and then sample all parts with same number of points. 2.6. Quasi-Monte Carlo Methods Quasi-Monte Carlo methods are based on the Koksma Hlawka inequality which states an upper boundpon the error of an integration formula Qn f = n1 ni=1 f (~xi ), Qn f If 6 V (f ) D (~x1,..., ~xn ). sup r [0,1]d ν(r) Vol r, n 2.7. Lattice Methods Lattice methods require a periodic integrand, usually obtained by applying a periodizing transformation (Cuba s Divonne uses x 2x 1 ). Sampling is done on an integration lattice L spanned by a carefully selected integer vector ~z: Ln f = 1 n i=0 f { ni ~z }, n = 2000 n = 3000 n = 4000 Mersenne Twister Pseudo-Random Numbers (12) where ν(r) counts the ~xi that fall into r. The word equidistributed indeed commonly means that ν(r) is proportional to Vol r. Quasi-random sequences can be constructed with a substantially lower discrepancy than (pseudo-)random numbers. A Monte Carlo algorithm based on these sequences typically achieves convergence rates of O(logd 1 n/n) rather than the usual O(1/ n). Cuba offers a choice of quasi-random Sobol sequences [4] or pseudo-random Mersenne Twister sequences [5] for all Monte Carlo algorithms. Figure 1 shows that quasi-random numbers cover the plane much more homogeneously than pseudorandom numbers. n 1 X n = 1000 (11) Apart from choosing a different integrand there is little one can do about V (f ), the variation in the sense of Hardy and Krause. The discrepancy D of a sequence ~x1,..., ~xn is defined as D = Sobol Quasi-Random Numbers (13) {x} = fractional part of x. ~z is chosen (by extensive computer searches) to knock out as many low-order Bragg reflections n = 1000 n = 2000 n = 3000 n = 4000 Figure 1. Comparison of sequences. as possible in the error term (see e.g. [6]): Ln f If = = X ~ k Zd ~ f (~k) Ln e2πi k ~x f (~0) X f (~k), (14) ~ k L, ~ k6=~0 where L = {~k Zd : ~k ~z = 0 (mod n)} is the reciprocal lattice. 3. Implementation 3.1. Vegas Vegas is Lepage s classic Monte Carlo algorithm [7]. It uses importance sampling for vari-

4 T. Hahn Max-Planck-Institut für Physik Föhringer Ring 6, D 80805 Munich, Germany ance reduction for which it iteratively builds up a piecewise constant weight function, represented on a rectangular grid. Each iteration consists of a sampling step followed by a refinement of the grid. In Cuba s implementation Vegas can memorize its grid for subsequent invocations and it can save its internal state intermittently such that the calculation can be resumed e.g. after a crash. 3.2. Suave Suave is a cross-breed of Vegas and Miser [8], a Monte Carlo algorithm which combines Vegasstyle importance sampling with globally adaptive subdivision. The algorithm works as follows: Until the requested accuracy is reached, bisect the region with the largest error along the axis in which the fluctuations of the integrand are reduced most. Prorate the number of new samples in each half for its fluctuation. The Vegas grid is kept across divisions, i.e. a region which is the result of n 1 subdivisions has had n Vegas iterations performed on it. On the downside, Suave is somewhat memory hungry, as it needs to retain samples for later use. 3.3. Divonne Divonne is a significantly extended version of CERNlib s Algorithm D151 [9]. It is essentially a Monte Carlo algorithm but has cubature rules built in for comparison, too. Variance reduction is by stratified sampling, which is aided by methods from numerical optimization. Divonne has a three-phase algorithm: Phase 1: Partitioning The integration region is split into subregions of (approximately) equal spread s, defined as s(r) = Vol r ( 2 max x r ) f( x) min f( x). (15) x r Minimum and maximum of each subregion are sought using methods from numerical optimization (essentially a quasi-newton search). Then, dividers are moved around (see picture) to find the optimal splitting. This latter procedure can cleverly be translated into the solution of a linear system and is hence quite fast (for details see [9]). Phase 2: Sampling The subregions determined in Phase 1 are independently sampled with the same number of points each. The latter is extrapolated from the results of Phase 1. Phase 3: Refinement Regions whose results from Phase 1 and 2 do not agree within their errors are subdivided or sampled again. This phase is an addition to the original algorithm since it was found that often enough the error estimate, or even the integral value, was off because characteristics of the integrand had not been found in Phase 1. Two important features have been added in the Cuba implementation: The user can point out extrema for tricky integrands. For integrands which cannot be sampled too close to the border, a safety distance can be prescribed within which values will be extrapolated from two points in the interior. 3.4. Cuhre Cuhre is a deterministic algorithm. It uses the Genz Malik cubature rules [2] in a globally adaptive subdivision scheme. The algorithm is thus: Until the requested accuracy is reached, bisect the region with the largest error along the axis with the largest fourth difference. Cuhre has been re-implemented in Cuba mostly for a consistent interface, it is the same as the original DCUHRE subroutine [10]. 4. Comparison Doing a balanced comparison on integration algorithms is nearly hopeless. Performance depends highly on the integrand and there are always cases, and not just academic ones, in which one routine outperforms the others, or conversely,

The Cuba Library 5 in which one routine simply gives wrong results. This, of course, is the main reason why there are four independent and easily interchangeable algorithms in the Cuba library. In this context it should be pointed out that the statistical error estimate quoted by the Monte Carlo algorithms merely states the one-sigma interval, or in other words: the probability that the central value lies in the given interval is (only) about 68%. With these caveats, the following plot compares the performance of the four Cuba routines on a real phase-space integration. The results obtained by the four methods (not shown here) indeed agree to within the requested accuracy. 10 6 10 5 10 4 10 3 400 500 Integrand evaluations 600 700 800 900 5. Mathematica interface 1000 e + e t t γ ε rel = 3 10 3 Cuhre Suave Vegas Divonne s/gev The Mathematica interface deserves a special mention, as it is not a library in the proper sense. It is rather four executables which communicate with Mathematica via the MathLink API: Mathematica Vegas[f,...] MathLink C void Vegas(...) integrand f (compiled function) { x 1, x 2,... } {f 1, f 2,... } request samples After loading the appropriate MathLink executable, e.g. with Install["Vegas"], the corresponding routine can be used almost like Mathematica s native NIntegrate. The integrand is evaluated completely in Mathematica, which means that one can do things like Cuhre[Zeta[x y], {x,2,3}, {y,4,5}] 6. Further Tools 6.1. Chooser Cuba includes a one-stop interface which further simplifies the invocation: subroutine Cuba(method, ndim, ncomp, integrand, integral, error, prob) The user just has to choose method = 1,2,3,4 to switch between Vegas, Suave, Divonne, Cuhre. All parameters specific to individual routines are hidden (determined inside the routine), i.e. this is not a finished product, but should be adapted by the user. 6.2. Partition Viewer Cuba s Partition Viewer displays the partition taken by the integration algorithm. This is sometimes helpful to visualize where the integrand s characteristic regions lie. It is really useful only in small to moderate dimensions, though. Verbosity level 3 must be chosen in the integration routine and the output piped through the partview utility, as in myprogram partview 1 2 which will then display the 1 2 plane of the partitioning. Figure 2 shows a screenshot. 7. Summary Cuba is a library for multidimensional numerical integration written in C. It contains four independent algorithms: Vegas, Suave, Divonne, and Cuhre which have similar invocations and can be exchanged easily for comparison. All routines can integrate vector integrands and have a Fortran, C/C++, and Mathematica interface. Additional tools are included, such as a one-stop invocation and a partition viewer. Cuba is available at http://www.feynarts.de/cuba, licensed under the LGPL, and easy to build (autoconf). REFERENCES 1. T. Hahn, Comp. Phys. Commun. 168 (2005) 78 [hep-ph/0404043].

6 T. Hahn Max-Planck-Institut für Physik Föhringer Ring 6, D 80805 Munich, Germany Figure 2. Screenshot of Cuba s partition viewer. 2. A. Genz, A. Malik, SIAM J. Numer. Anal. 20 (1983) 580. 3. W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery, Numerical recipes in Fortran, 2 nd edition, Cambridge University Press, 1992. 4. P. Bratley, B.L. Fox, ACM Trans. Math. Software 14 (1988) 88. TOMS algorithm 659. 5. M. Matsumoto, T. Nishimura, ACM Trans. Modeling Comp. Simulation 8 (1998) 3 and http://www.math.sci.hiroshima-u.ac.jp/ m-mat/mt/emt.html. 6. H.L. Keng, W. Yuan, Applications of number theory to numerical analysis, Springer-Verlag, 1981. 7. G.P. Lepage, J. Comp. Phys. 27 (1978) 192. G.P. Lepage, Report CLNS-80/447, Cornell Univ., Ithaca, N.Y., 1980. 8. W.H. Press, G.R. Farrar, Comp. in Phys. 4 (1990) 190. 9. J.H. Friedman, M.H. Wright, ACM Trans. Math. Software 7 (1981) 76. J.H. Friedman, M.H. Wright, SLAC Report CGTM-193-REV, CGTM-193, 1981. 10. J. Berntsen, T. Espelid, A. Genz, ACM Trans. Math. Software 17 (1991) 437 and 452. TOMS algorithm 698.