CSE541 Homework #7
Answers to programming questions
Answer to 7.2.14 (pdf)
Answer to 8.1.2 - A (pdf)
Answer to 8.1.2 - B (pdf)
Due Date: Tuesday, Mar. 6
- Hardcopy written or typed answers are due at the beginning of class on the due date.
- Software (source files and single makefile) is to be submitted (via the 'submit' command) by 3:00 on the due date (before class)
FINALIZED
GENERAL INSTRUCTIONS
-
Homework is due in lecture when I ask for it.
-
All work must be your own. You are not allowed to work in groups or use third party sources.
-
Computer problems must be done using C/C++. Turn in a hard copy of your code and print-outs of your sample runs. Please keep this concise, i.e. I don't want you to turn in a lot of pages.
-
All make-ups for homework must be accompanied by a documented and verifiable excuse well before the deadline. Given the severity of the emergency please inform me as soon as possible.
-
Please make sure your homework answers are legible, otherwise they will be marked wrong.
-
Staple your pages.
-
Homework submissions will NOT be accepted via email to me or the grader. No late homework will be accepted.
-
For each problem, SHOW ALL WORK in order to receive full credit. Just giving a final answer (correct or incorrect) will receive NO CREDIT. Thus, you will be graded on the work shown.
- Each problem is worth the same amount (including the program and associated explanation).
- Similarly, each of the n homework assignments will be worth 1/nth of the total for Assignments.
'n' is yet to be determined, but should be around 7.
PROGRAMMING ASSIGNMENT
Write a program that will:
- implement Monte Carlo integration
- use the following command line arguments:
- id: function id: 1 to 3
- seed: seed value for random function
- num: number of points to use
To get you started, here is a program and makefile that implements integration estimation by uniform sampling and prints out the result.
QUESTIONS
On the due date, at the beginning of class, hand in hardcopy of
- (25%) Problem 7.2.14 from the book, 5th edition
[see problems (pdf)]
- (25%) Problem 8.1.2 from the book, 5th edition
[see problems (pdf)]
- (50%) Include a printout of the relevant program results, as described above, and answer the following questions:
- For a given seed value, for each of the functions, find the number of points needed to be within 0.0001 of the correct answer (within an order of magnitude - for example, 10,000 points v. 1,000 points)
- For each of the functions, Try different seeds and comment on the dependence of the results on the see value.
- For each of the functions, compare integration using uniform sampling to integration using Monte Carlo integration for various numbers of points and comment on which is best for which function and why.
- For function 2, basically sin(100*pi*x), what choice for number of points could be bad for the uniform sampling estimate to the integral?
SPECIFIC INSTRUCTIONS
With respect to the lab assignment,
-
Electronically 'submit' the makefile and source code files.
The assignment is called 'hw7':
submit hw7 integrate.c Makefile
-
Put all the integration methods in one executable;
call the executable 'integrate'.
-
DO NOT SUBMIT THE EXECUTABLE.
-
Modify the makefile that the grader can use to create your executables.
The grader should be able to go into your submit directory, make your executables and then run it, for example:
make
integrate 1 3 10000
and the program should print out all of the output from the various methods in each case.
-
As before, you can capture the output to a file by:
integrate 1 1 10000 > hw7.txt
integrate 2 5 10000 >> hw7.txt
and then edit that file or include all of it in what you hand in in class.
In your discussions, refer to the printed output that you hand in.
NOTES