{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L12post

# L12post - Previous Lecture Probability and random numbers...

This preview shows pages 1–8. Sign up to view the full content.

Previous Lecture: Probability and random numbers 1-d array—vector Today’s Lecture: More examples on vectors Simulation Announcements: Section in the lab (UP B7) this week Prelim 1 Thursday 7:30-9pm. Check website for where to go.

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

View Full Document
October 6, 2009 Lecture 12 Simulation Imitates real system Requires judicious use of random numbers Requires many trials Æ opportunity to practice working with vectors!
October 6, 2009 Lecture 12 5 Simulate twinkling stars Get 10 user mouse clicks as locations of 10 stars—our constellation Simulate twinkling Loop through all the stars; each has equal likelihood of being bright or dark Repeat many times Can use DrawStar, DrawRect

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

View Full Document
% No. of stars and star radius N=10; r=.5; % Get mouse clicks, store coords in vectors x,y [x,y] = ginput(N); % Twinkle! for k= 1:50 % 50 rounds of twinkling end
% No. of stars and star radius N=10; r=.5; % Get mouse clicks, store coords In vectors x,y [x,y] = ginput(N); % Twinkle! for k= 1:20 % 20 rounds of twinkling end Loop through all stars. Each has 50% chance of being “lit”—draw in yellow. Otherwise draw in black.

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

View Full Document
October 6, 2009 Lecture 12 8 Twinkle.m
October 6, 2009 Lecture 12 9 2-dimensional random walk N = 11 Hops = 67 Start in the middle tile, (0,0). For each step, randomly choose between N,E,S,W and then walk one tile.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 34

L12post - Previous Lecture Probability and random numbers...

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

View Full Document
Ask a homework question - tutors are online