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

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

View Full Document Right Arrow Icon
± 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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
October 6, 2009 Lecture 12 2 Simulation ± Imitates real system ± Requires judicious use of random numbers ± Requires many trials ± Æ opportunity to practice working with vectors!
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
% 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
Background image of page 4
% 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.
Background image of page 5

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

View Full DocumentRight Arrow Icon
October 6, 2009 Lecture 12 8 Twinkle.m
Background image of page 6
October 6, 2009 Lecture 12 9 2-dimensional random walk N = 11 Hops = 67 Start in the middle tile, (0,0).
Background image of page 7

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

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

This note was uploaded on 03/06/2010 for the course CS 9339 taught by Professor Gries during the Fall '09 term at Cornell University (Engineering School).

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 Right Arrow Icon
Ask a homework question - tutors are online