## MCS 507 --- Individual Computer Project 4 --- Fall 2004 Comparison of Integration Methods in Multi-dimensions: Midpoint Rule and Pseudo-Monte Carlo and Quasi-Monte Carlo:

(Revised, 01 December 2004)
Computer Project Report is Due Friday 03 December 2004 in class,
Revised to now be due 07 December 2004 under Prof. Hanson's Office door at 718 SEO.
.

• General Project Objectives: Testing is needed for methods for computing multi-dimensional integrals (here denoted by integral(f,[a,b]) for the integral over function f of d-dimensional vector argument x=[x(i)]d×1 over a HyperRectangle given by opposite corner vectors [a,b]) based on better efficiency and accuracy. An appropriate sample d-dimensional integral is given as the expectation or mean,

I_d = E[f(x)|a<x<b]=integral(f(x)*p(x),[a,b]),

where, in MATLAB notation,

f(x) = max(sum(exp(0.06325*s.*x))-K,0)

denotes roughly the payoff for a basket option with i=1:d stocks,

p(x) = (2*pi)^(-d/2)*exp(-0.5*sum((x-c).*(x-c)./(s.^2)))/prod(s),

(Changes: matched ")" and replaced "sum(s.*s)" by "prod(s)", 01dec04)
denotes the d-dimensional normal density with vector mean c and scalar standard deviation s, where pi is area of a circle of unit radius.

Integration Methods:
The objective is to compute the the integral, using either MATLAB or C/F programming languages, by several integration methods:

1. Multi-dimensional Midpoint Rule (MPR) using for this example M=16 midpoints within each evenly spaced subinterval of vector length h=(b-a)/M along each dimension so that there are Nmpr=Md total approximation points.

2. Pseudo Monte Carlo (PMC) estimates with variance based on both
• normal deviates with the method of acceptance/rejection and
• uniform deviates
using a total of Npmc points in the d-dimension, i.e, so that Npmc=Nmpr. Caution: for the first part you will need to scale the integral so that the density p(x) is transformed to the standard zero mean and unit variance used by MATLAB's "randn" See class MATLAB examples
Also, noting that since the intervals are finite, the method of acceptance/rejection must be used to exclude normal pseudo-random deviates outside the interval of integration when computing your sample average estimate for f(x), but be sure to use the full point count and be sure your scaling is correct.}

3. Quasi-Monte Carlo (QMC) estimates based on both uniform quasi-random
• halton sequences
• Sobol' sequences
in multi-dimensions using a the closest number of points N(qmc) in dimension d so the order of the error is comparable to that used in MPR. See that used in MPR (for the revision, then make the N the same as for MPR). using same total of number of points N points in MPR. in the d-dimension. { Code can be converted to MATLAB or perhaps you can find a MATLAB version on line, which are strongly recommended.}

Validation and Performance Testing:

• Random Number Testing: Test any random number generator you use in the state/seed that you use it in (e.g., state 3 of randn is known to generate poor values). Check the means and standard deviations and do a statistical test, either chisquares or KS or spectral (plotting samples x(k+1) versus x(k)) tests.
For PMC, compute the 95% confidence intervals using the sample variance corresponding to the sample mean of f(x)
• Time each method using a timer function with sufficient resolution.
• Compare accuracy of the results for each integral against a more refined Sobol' calculation with 4 times the number of points used.
• Test accuracy also by using  p(x)f(x) = 1 for uniform RNG methods or  f(x) = 1 for normal RNG type methods.

{MATAB-C++ Conversion Hints: DP=DoublePrecision=double (default for MATLAB); Vec_*=Vector; ULNG=UnsignedLong; Mat_*= Matrix; regn.size=SizeDetector (dimensions are optional in MATLAB as long a properly referenced; size is a built-in function); SQR=SquaringFunction; MAX=max; MIN=min;}

• Input Requirements for Testing: Professional code should be for the general problem and not specialized to a particular set of input used for testing here:

1. Dimension: d=5;

2. Strike: K=2; (Was: K=5.5; 01dec04)

3. Population Mean: c=( +5.2386, -3.5134, -0.2588, +1.5783, +4.1736 );

4. Standard Deviation: s=10*(0.1234,0.0855,0.1056,0.0755,0.1366); (Was: s=(0.1234,0.0855,0.1056,0.0755,0.1366); 01dec04)

5. HyperRectangular Left Endpoints; a=( -2.67, -6.89 -3.75, -3.45, -4.25 )

6. HyperRectangular Opposite/Right Endpoints; b=( +8.75, +3.36, +5.07, +2.85, +7.77 ).

• Report and Output Requirements: Write a combination of MATLAB m-file and/or f-file/c-file codes to solve this for part computer problem such that your report is

1. Cover Page.

2. Compiler and Hardware Specifications.

3. Executive Summary: Itemized list briefly summarizing the project report, describing problem, significant results in a table and recommenations to a busy Boss, summarizing a ranking on the methods in terms of performance, accuracy and validity.

4. Introduction: Motivation for the report.

5. Project and Methods: Well-documented with descriptions of the problem, variables and majors steps.

6. Results: Description of output in words to explain well-labeled output tables, collecting all integral estimates for easy comparison.

7. Discussion: Give a good discussion of your results: with regard to

• Comparison of the accuracy of each method, by presenting the relative errors of each of the methods with respect to a more accurate multi-dimensional Sobol' with 4× the total number of points, ranking the methods. Explain differences between each size (N(?)) for each method and also among the methods. Compare the errors for the the pure volume answers ((p(x)f(x) = 1) against the volume of the hypercube for uniform RNGs and an estimate for the normal RNGs (f(x) = 1).

• Comparison of the efficiency of each method by tabulating the time each method takes. In either MATLAB or C you can use the clock and etime functions, but it is better to find a timer with higher resolution. Rank the methods by time. Qualify your table in the text by specifying the platform you used for each method and the MATLAB/compiler versions used. Explain differences in timings, specifying units.

• Present validation test results like Chi-squares (e.g., chone) or KR.

8. Conclusions: What was primarily accomplished and what methods are recommended for accuracy and for speed?

9. Acknowledgements: Say who you consulted with and what sources were used.

10. Appendices: Codes and other supporting material.

• Project Resources:

1. UIC PCLabs MATLAB available software. Also check out your departmental computers such as in EECS and MSCS.

2. MATLAB Help Page (Hanson).

3. (NRC or NRCPP or NRF): William H. Press et al., Numerical Recipes in C (or F): The Art of Scientific Computing, Cambridge U. Press. { Click on Numerical Recipes Home Page}

4. William T. Vetterling et al., Numerical Recipes in C (or F): Source Code for Recipes and Example Programs/Disk, Cambridge U. Press.

Web Source: http://www.math.uic.edu/~hanson/mcs507/cp4f04.html

MCS 507 HomePage: http://www.math.uic.edu/~hanson/mcs507/

Email Comments or Questions to Professor Hanson