ScratchData LogoScratchData
Back to popswilson's profile

The Short Stick

POpopswilson•Created December 27, 2013
The Short Stick
3
1
47 views
View on Scratch

Instructions

Consider having an infinite supply of unit-length (length - 1) sticks. A random point is selected within the [0–1] interval and the stick is broken at that point. If this is repeated a lot of times, what is the average length of the shorter sticks? A simple Monte Carlo method for approximating the answer is coded in the algorithm. There is a theoretical answer (see Notes and Credits). Compare the Monte Carlo value [Average Length of Short Stick} variable as seen on screen with the theoretical value.

Description

Let x = the random break point on the [0 to 1] interval. then one part of the broken stick is x and the other part is (1–x). Test to determine which is the shorter part and add its length to the accumulated lengths of the shorter parts. Divide by the number of broken sticks to compute the average length of the short stick. If you click on 'See Inside' you will find that I tried to name the variables so that the code makes sense. For a probability problem for which I don't know the theoretical value but do know the Monte Carlo value see my Dancing Stick (http://scratch.mit.edu/projects/15998982/). You can argue that the theoretical value for the Average Length of Short Stick =0.05. Compare this value to the Monte Carlo value value in the project.

Project Details

Project ID16060866
CreatedDecember 27, 2013
Last ModifiedJanuary 31, 2015
SharedJanuary 30, 2015
Visibilityvisible
CommentsAllowed