Homework #7

All problems MUST be in a SINGLE *.m file and be in separate blocks using '%% Problem X'. Otherwise you will not receive credit. You may need additional files for class definitions or functions or PDF files. See class webpage for naming convention.

Contents

Problem 1

Generate a 1000 x 1 vector of numbers drawn from a normal (Gaussian) distribution with mean of 10 and standard deviation of 5. Check that the mean and standard devation of your vector are close to 10 and 5 respectively. Show the distribution of your vector using a histogram.

Hint:

help randn

Problem 2

Find the scalar value 'x' that minimizes

sum( (x-a).^2 )

where 'a' is your 1000 x 1 vector created in Problem 1. Use the Golden Section Search method to find the minimum.

Problem 3

Is the Golden Section really so golden? Systematically try the Golden Section search approach using ratios 'R' between 1 and 2 (Golden is 1.618) and see how many function evalulations are required to find the minimum of a fucntion to within a given tolerance. Use the simple function f(x) = (x-a)^2 like we did in class. Since there may be some effects from the position of the minimum, average the result over 1000 trials with randomly generated function minimums ('a' values) between 0 and 1. Use 0 and 1 as the bounds of your starting interval.

Plot the average number of function evaluationss required to converge versus 'R'.

Note: You will need to calculate 'r' from 'R' where:

[---a---|--b--]

R=a/b

and

r=a/(a+b)

Note 2: The ratio is only inforced when selecting the new X on the large interval. The resulting selected intervals will not, in general, have ratio R.

Problem 4

Use the 'publish' functionality to produce a PDF version of this homework. It doesn't have to look pretty.

+1 extra credit if it looks beautiful and clearly shows the results of your homework solutions.