Supported browsers: Internet Explorer 6.0+, Firefox 3.0+, Safari 3.0+, Chrome 5.0+, iPhone4 (partial support and may have to reload the page). Some graphics may not work in Opera.
Let's see what happens when we drop balls one at a time through a narrow chute and each ball moves left or right each time it hits a pin. See the diagram below. Pins are arranged in a regular grid of rows and columns. From one row to the next, the pins and columns shift laterally by half. At the bottom of the given number of rows, each ball remains captive in one of the bins: eleven bins in our case. Each ball hits ten pins before entering one of the eleven bins. (In our case, the final pin is the top of a wall between bins.)
We are interested in how many balls fall in each bin, which is called a (discrete) probability distribution. For our demo, balls start falling as soon as they clear each pin - we won't allow our balls to shoot across multiple columns horizontally. When a ball hits a pin, we have only two possible outcomes: fall immediately to the left or fall immediately to the right. Because each pin produces exactly two outcomes, the distribution of balls in bins is specifically called a binomial probability distribution.
(If the drawing canvas does not appear, is really short, or is blank, reload the page. The drawing canvas can be resized as you please (except on multitouch devices) by dragging and releasing the magenta drag-handle at the lower right of the canvas; the demo will restart.)
We learned about the mean or average value for all the balls in the bins. There is another useful statistical value - the median - which unfortunately is frequently confused with the mean. Sometimes the mean and median are nearly identical in value but in other cases they may be vastly different. Let's learn about the median but not using the demo of balls falling onto pins.
Suppose we have a set of values that we are given, interested in, or working with. We sort the values from smallest to largest. If some values are duplicated, we do not delete duplicates. After sorting, the value that is in the middle of the sorted list is the median value. Let's try an example. Here is a set of data: {295, 4, 1}. What are the mean and median values?
There are three values in this data set. The mean (average) value is (295 + 4 + 1)/3 = 300/3 = 100. Now let's calculate the median value. Here is the data sorted least to most: {1, 4, 295}. The value in the middle of the three values is the second value in the sorted list: 4. The mean is 100, the median is 4: much different and we should not confuse them.
Let's try a different example. Here is a different set of data: {295, 4, 1, 20}. The mean (average) value is (295 + 4 + 1 + 20)/4 = 320/4 = 80. Now let's calculate the median value. Here is the data sorted least to most: {1, 4, 20, 295}. Since there are four values - an even number of values - none of the values are the middle value. The middle is somewhere between 4 and 20. We'll use the exact middle between 4 and 20: (4 + 20)/2 = 24/2 = 12. The mean is 80, the median is 12: much different and we should not confuse them.
This demo correctly represented the probability distributions but did not faithfully represent gravitational acceleration, air resistance, and elastic (bouncy) collision of the balls with the pins. Following are some other persons' demos.
Following are some related Wikipedia articles.
This demo was suggested by my friend Paulo.
I hope you found this interesting, useful, and/or fun. Is there a demo you would like me to add? Would you like to be notified when a new demo is available? Links for sharing, reporting a problem, or emailing me are available in the pull-down menu at the top of the page. Feel free to link to my pages, screencast them to YouTube, or reuse my source code with attribution (MIT-style license).
Friend Links
Recommended Links