MIT6_094IAP10_assn04

MIT6_094IAP10_assn04 - Jan 28 2010 Homework 4 6.094...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Jan. 28, 2010 Homework 4 6.094: Introduction to Matlab Homework 4 This homework is designed to give you practice with more advanced and specific Matlab functionality, like advanced data structures, images, and animation. As before, the names of helpful functions are provided in bold where needed. Homework must be submitted before the start of the next class. What to turn in: Copy the text from your scripts and paste it into a document. If a question asks you to plot or display something to the screen, also include the plot and screen output your code generates. Submit either a *.doc or *.pdf file. Keep all your code in scripts/functions. If a specific name is not mentioned in the problem statement, you can choose your own script names. 1. Random variables. Make a vector of 500 random numbers from a Normal distribution with mean 2 and standard deviation 5 ( randn ). After you generate the vector, verify that the sample mean and standard deviation of the vector are close to 2 and 5 respectively ( mean , std ). 2. Flipping a coin. Write a script called coinTest.m to simulate sequentially flipping a coin 5000 times. Keep track of every time you get ‘heads’ and plot the running estimate of the probability of getting ‘heads’ with this coin. Plot this running estimate along with a horizontal line at the expected value of 0.5, as below. This is most easily done without a loop (useful functions: rand , round , cumsum ). Sample Probability of Heads in n flips of a simulated coin 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 Number of coin flips 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Probability of heads Sample Probability Fair coin 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Jan. 28, 2010 Homework 4 6.094: Introduction to Matlab 3. Histogram. Generate 1000 Poisson distributed random numbers with parameter λ = 5 ( poissrnd ). Get the histogram of the data and normalize the counts so that the histogram sums to 1 ( hist – the version that returns 2 outputs N and X, sum ). Plot the normalized histogram (which is now a probability mass function) as a bar graph ( bar ). Hold on and also plot the actual Poisson probability mass function with = 5 as a line ( poisspdf ). You can try doing this with more than 1000 samples from the Poisson distribution to get better agreement between the two. Poisson distribution and observed histogram 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Value 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 Probability Experimental histogram Actual Poisson Distribution 2
Background image of page 2
Jan. 28, 2010 Homework 4 6.094: Introduction to Matlab 4. Practice with cells. Usually, cells are most useful for storing strings, because the length of each string can be unique. a. Make a 3x3 cell where the first column contains the names: ‘Joe’, ’Sarah’, and ’Pat’, the second column contains their last names: ‘Smith’, ‘Brown’, ‘Jackson’, and the third column contains their salaries: $30,000, $150,000, and $120,000. Display the cell using disp . b.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/27/2011 for the course CS 1671 taught by Professor Smith during the Spring '11 term at Georgia Tech.

Page1 / 10

MIT6_094IAP10_assn04 - Jan 28 2010 Homework 4 6.094...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online