User Tools

Site Tools


gibson:teaching:fall-2014:math445:lab3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:fall-2014:math445:lab3 [2014/09/15 11:56]
gibson removed
gibson:teaching:fall-2014:math445:lab3 [2014/09/15 12:05]
gibson
Line 1: Line 1:
-====== Math 445 Lab 3: Array operations and basic plotting ​======+====== Math 445 Lab 3: graphical data analysis  ​======
  
-Helpful Matlab functions+For this lab you will deduce the functional relationship between variables in data sets using graphical analysis.  
 +The data sets are given as // N x 2// matrices with //x// as the first column and //y// as the second.  
 +For each data set, you will find a function //y(x)// that fits the data, using the following steps:
  
-  ​sumany, alllinspace +  ​- Cut & paste the data set to a text file with an appropriate namee.g. ''​earthquakes.asc''​ for problem 1. 
-  plot, semilogy, semilogx, ​xlabel, ylabel, legendaxis+  - Load the dataset to Matlab with ''​load''​. 
 +  - Extract the two columns of the loaded data into two appropriately named vectorse.g. //R// and //N// for problem 1. For the remaining generic instructions I'll use the names ''​x''​ and ''​y''​. 
 +  ​- Experiment with ''​plot''​''​semilogy''​''​semilogx''​and ''​loglog''​ to determine the functional relationship between ''​y''​ and ''​x''​. 
 +  - Estimate the constants in the log-linear relationship graphically to determine the function.  
 +  - Plot the estimated function and the data togetherand fine-tune your function by adjusting the constants until there is a good fit between the function and the data.
  
-**Problem 1:** Write a Matlab expression that sums the first N of each series ​and evaluate it for N=100.+Once you have good fit between ​the data and the function, make a plot that shows
  
-(a) 1 + 1/2 + 1/3 + 1/4 + ... \\ +  * the data set'​s ​//y// versus ​//x// as red circles 
-(b) 1 + 1/2 + 1/4 + 1/8 + ... \\ +  * your function ​//y(x)// as a solid blue line 
-%%(c)%% 1 + 1/3 + 1/9 + 1/27 + ...\\ +  ​* a legend indicating the meaning of each plotting symbol 
-(d) 1/2 + 2/3 + 3/4 + 4/5 + ...\\ +  appropriate labels for each axis and a title
-(e1/2 - 2/3 + 3/4 - 4/5 + ...\\ +
-   +
-**Problems 2,3 and 4:**  +
-Test that your expression gives the right answer on good set of test vectors. +
-But please turn in just the general Matlab expression, not the tests.+
  
 +For each data set, turn in your plots and your estimate of the function //y(x)//.
  
-**Problem ​2:**  Given vectors x,y of the same lengthwrite expression ​that has value  +**Problem ​1The distribution of earthquake magnitudes, by Moment Magnitude scale.** Big earthquakes are rareand  
-true (1) if **each** component of x is greater than the corresponding ​ +little earthquakes are frequent. In factthere is a very clean empirical law that governs how many earthquakes of a  
-component of y, false otherwise.+given magnitude typically occur world-wide in a given year. Your job is to deduce that law from the following ​ 
 +historical data.
  
-**Problem ​3:** Given vectors x,y of the same length, write expression that has value  +<​code>​ 
-true (1) if **any** component of x is greater than the corresponding ​ +% M N 
-component of y, false otherwise.+8 2 
 +7 18 
 +6 120 
 +5 800 
 +4 6200 
 +49000 
 +2 365000 
 +2920000 
 +</​code>​
  
-**Problem 4:** Given vector xwrite expression that has value true (1) if the elements ​of +The first column is the [[http://​en.wikipedia.org/​wiki/​Moment_magnitude_scale | moment magnitude]] //M//and the second column is the number of earthquakes //N// of that magnitude that occuron average, in a year. The last two entries are estimates, since it's impossible to detect every small earthquake around ​the world. The data are obtained from [[http://​www.earthquake.ethz.ch/​education/​NDK/​NDK|Earthquake Statistics ​and Earthquake Prediction Research]] by Stefan Wiemer, Institute of Geophysics, Zurich.
-are sorted in increasing order (that isif no element is less than the previous element) ​and +
-false otherwise.+
  
-**Problems 5-11:** Turn in the Matlab ​code and the figuresAlways label the figures appropriately,​ using ''​title'',​ ''​xlabel'' ​and either ''​ylabel''​ or ''​legend''​. The figures should be titled "​Problem 5", etc. Read ''​help''​ for the following functions ​and then experiment with them to see how they affect ​the plot.+Using Matlab ​plotting commands, deduce the form of the functional relationship //N(M)//Estimate  ​the constants in the relationship by estimating the slope and the //​y//​-intercept, ​and then fine-tuning by matching ​the plot of your estimate against the plot of the data
  
-  clf +**Problem 2: The distribution of earthquake magnitudes, by energy.** The moment magnitude scale is logarithmic,​ in that an earthquake of magnitude //M+1// releases about 32 times energy than an earthquake of magnitude //M//. The following data 
-  hold on +set gives the number //N// of earthquakes in a given year of energy //E// measured in Joules. ​ 
-  hold off +<​code>​ 
-  ​figure +% E  N 
-  grid +6e16 2 
-  ​xticks +2e15 18 
-  ​yticks ​+6e13 120 
 +2e12 800 
 +6e10 6200 
 +2e09 49000 
 +6e07 365000 
 +1e06 2920000 
 +</​code>​
  
-**Problem 5:** Plot sin(xversus x for 100 evenly space points ​in x from 0 to 2piusing a solid blue line.+Deduce the form of the functional relation //E(N)// using Matlab plotting, then estimate and fine-tune the constants 
 +in the relationjust as in problem 1.
  
-**Problem ​6:** Plot sin(x) in redcos(x) ​in green, over same x as problem 5Use '​legend'​ to indicate which function is shown in which color+**Problem ​3World population.** The following data set provides the human population //P// of the earth at a given  
 +time //t//measured ​in years A.D.
  
-**Problem 7:** Plot $y = 5x^2 - 4x - 3$ for 100 evenly space points in x from -2 to 2. Superimpose an x,y grid on the plot.+<​code>​ 
 +% t   P 
 +1927 2e09 
 +1960 3e09 
 +1974 4e09 
 +1987 5e09 
 +1999 6e09 
 +2011 7e09 
 +</​code>​ 
 +  
 +Deduce ​the form of the functional relation //P(t)// and determine the constants graphically
  
-**Problem 8:** Make a plot of the unit circleMake sure it's closed --no gap! Hint: use ''​linspace''​ to specify a range of angles, then ''​cos''​ and ''​sin''​ to produce vectors ​of the x,y coordinates of points on the unit circle.+Assume that the formula you derived for //P(t)// is valid indefinitely into the future and the pastWhat year will  
 +the population ​of the earth reach one trillion? What year were the first humans born? Do you believe these answers? 
 +If notwhy not?
  
-**Problem 9:**  Plot $10^{3x}$ for 100 points x evenly space between -2 and 5. Choose the most 
-appropriate plotting function. Hint: it ain't ''​plot''​! 
-  ​ 
-**Problem 10:** Plot $3 x^5$ for 100 points x evenly space between 1 and 4. Choose the most 
-appropriate plotting function. Again, it ain't ''​plot''​! 
- 
-**Problem 11:** Make a histogram of 1000 random numbers from a normal (Gaussian) distribution. ​ 
  
gibson/teaching/fall-2014/math445/lab3.txt · Last modified: 2014/09/15 12:05 by gibson