Lab Exercises


Exercise 1.

For fun: download a workplace friendly image/photo, or use one you have already (jpg or png format should be fine). Use matplotlib to convert the image to a float point array. (If you have a color image, average the the [RGB] colors together.) Write the array to a new image file (jpg or png) and save it. Check that you recover the original image, or at least a black-n-white version of it. [I used imread/imsave.] Treating the image as a matrix, perform SVD on it (A=U.S.Vt). Note the values in the diagonal elements of the S array. See how many you can zero out without degrading the image quality. (This is an example of image compresshion....)

Exercise 2.

In this exercise, generate mock data for this function

y = (0.5-x)*(1.5+x)*(1-x)+noise
where "noise" is a normal deviate with mu=0 and s.d.=0.5. Choose n=15 samples in x, evenly spaced in the interval [-2,+2]. Fit the mock data with

Exercise 3.

For the mock data in the previous exercise, fitted with your favorite method (other than bootstrap, which of course is everyone's real favorite), estimate a p-value for your fit. Try using an unrealistically small value for the error in your fit, and again with a lartge value. How does the p-value change?