View
218
Download
0
Category
Preview:
Citation preview
Random Warmup
Finding a Short Story
• Suppose a book of short stories has both shorter short stories and longer short stories.
• Their order within the book is random.
• You want to pick a random story to read, but you would prefer it is a shorter one.
Finding a Short Story
• Two Strategies– Strategy #1: Flip to a random page, back
up to the beginning of that story, and start reading
– Strategy #2: Flip to a random page, go forward to the beginning of the next story, and start reading• (Go to first story if you are at the end of the
book)
• Does it matter which strategy you use?
To What Kind of Story Is a Random Page Likely to Belong
• To be concrete, suppose there are 20 stories – 10 of them are 10 pages long– 10 of them are 20 pages lon
• So book is 300 pages long• The Expected #pages in the story on a
random page is (200∙20+100∙10)/300 = 16.7
• When you pick a random page, it will belong to a longer story with probability 2/3
The Second Strategy Works Better!
• Strategy #1 will have you reading a longer story with probability 2/3 and a shorter story with probability 1/3
• Strategy #2 will take you to the beginning of a random STORY
• So Strategy #2 will take you to the beginning of a longer story with probability ½ and a shorter story with probability ½
FINIS
Recommended