MIT6_094IAP10_lec04 - 6.094 Introduction to programming in MATLAB Lecture 4 Advanced Methods Danilo epanovi IAP 2010 Homework 3 Recap How long did

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

View Full Document Right Arrow Icon
6.094 Introduction to programming in MATLAB Danilo Š ć epanovi ć IAP 2010 Lecture 4: Advanced Methods
Background image of page 1

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

View Full DocumentRight Arrow Icon
Homework 3 Recap • How long did it take? • Common issues: • The ODE file should be separate from the command that solves it. ie. you should not be calling ode45 from within your ODE file • The structure of the output of an ode solver is to have time running down the columns, so each column of y is a variable, and the last row of y are the last values • HW 4 was updated today, so download it again if you already started. Show a juliaAnimation • Today is the last required class: make sure the sign-in sheet is accurate regarding your credit/listener status
Background image of page 2
Outline (1) Probability and Statistics (2) Data Structures (3) Images and Animation (4) Debugging (5) Online Resources
Background image of page 3

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

View Full DocumentRight Arrow Icon
Statistics • Whenever analyzing data, you have to compute statistics » scores = 100*rand(1,100); • Built-in functions ¾ mean, median, mode • To group data into a histogram » hist(scores,5:10:95); ¾ makes a histogram with bins centered at 5, 15, 25…95 » N=histc(scores,0:10:100); ¾ returns the number of occurrences between the specified bin edges 0 to <10, 10 to <20…90 to <100. you can plot these manually: » bar(0:10:100,N,'r')
Background image of page 4
Random Numbers • Many probabilistic processes rely on random numbers • MATLAB contains the common distributions built in » rand ¾ draws from the uniform distribution from 0 to 1 » randn ¾ draws from the standard normal distribution (Gaussian) » random ¾ can give random numbers from many more distributions ¾ see doc random for help ¾ the docs also list other specific functions • You can also seed the random number generators » rand('state',0); rand(1); rand(1); rand('state',0); rand(1);
Background image of page 5

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

View Full DocumentRight Arrow Icon
Changing Mean and Variance • We can alter the given distributions » y=rand(1,100)*10+5; ¾ gives 100 uniformly distributed numbers between 5 and 15 » y=floor(rand(1,100)*10+6); ¾ gives 100 uniformly distributed integers between 10 and 15. floor or ceil is better to use here than round » y=randn(1,1000) » y2=y*5+8 ¾ increases std to 5 and makes the mean 8 -25 -20 -15 -10 -5 0 5 10 15 20 25 0 50 100 150 200 250 300 350 400 -25 -20 -15 -10 -5 0 5 10 15 20 25 0 10 20 30 40 50 60 70 80 90
Background image of page 6
Exercise: Probability • We will simulate Brownian motion in 1 dimension. Call the script ‘brown’ • Make a 10,000 element vector of zeros • Write a loop to keep track of the particle’s position at each time • Start at 0. To get the new position, pick a random number, and if it’s <0.5, go left; if it’s >0.5, go right. Store each new position in the k th position in the vector • Plot a 50 bin histogram of the positions.
Background image of page 7

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

View Full DocumentRight Arrow Icon
Exercise: Probability • We will simulate Brownian motion in 1 dimension. Call the script ‘brown’ • Make a 10,000 element vector of zeros • Write a loop to keep track of the particle’s position at each time • Start at 0. To get the new position, pick a random number, and if it’s <0.5, go left; if it’s >0.5, go right. Store each new position in
Background image of page 8
Image of page 9
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 Institute of Technology.

Page1 / 34

MIT6_094IAP10_lec04 - 6.094 Introduction to programming in MATLAB Lecture 4 Advanced Methods Danilo epanovi IAP 2010 Homework 3 Recap How long did

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

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