Showing posts with label probability. Show all posts
Showing posts with label probability. Show all posts

Friday, December 4, 2015

Random Walk Probabilities

   A mathematician is performing a probability experiment.  Starting from 0 (zero) on the integer number line, the mathematician flips a coin and takes one step to the right if it comes up a head or one step to the left if a tail. This process of flipping and moving either right or left is repeated for a given number of flips of the coin.
   This project computes the probability of ending the walk at position p after f flips of the coin.
   Here is a screenshot reporting the probability of ending a random walk at +3 after 5 flips as 5/32 instead of its decimal equivalent 0.15625.

   Note that the screen shows the positions that can be reached for a given number of flips as red-rimmed black circles. Those that cannot be reached as a function of the number of flips are represented as white circles.
   The number of possible paths to each possible position for a given number of flips is shown as a number above each possible position. It’s an interesting fact that these numbers are given by Pascal’s triangle and the nCr notation for combinations computes these numbers. The screen also shows that the totals number of possible paths for a given number of flips is a power of 2.
   The probability for ending a walk at position p after f flips is the number of paths to position p divided by the total number of paths for the given number of flips.
   This is the link to this project, Random Walk on the Integer Number Line Probabilities.
https://scratch.mit.edu/projects/86951083/
   A detailed explanation of the mathematics and the programming used in the project, including a couple of additional programming simplifications, are detailed in document that is available at no cost by sending an email request to grandadscience.com.
   This Scratch project needed a power of 2 script, a factorial script, and a nCr script that are available as separate Scratch projects by clicking on the links as shown below.
Combinations
https://scratch.mit.edu/projects/88028765/
Factorial
https://scratch.mit.edu/projects/87399897/
Powers of 2 Calculator
https://scratch.mit.edu/projects/86877882/
These are the links to my other Random Walk on the Integer Number Line projects.
Feynman’s Random Walk
https://scratch.mit.edu/projects/11282377/
Random Walk with Barriers
https://scratch.mit.edu/projects/11300964/

Thursday, August 27, 2015

The Grecian Urn Problem


   The following problem is one of three problems A. K. Dewdney discussed in his Mathematical Recreations column appearing in the March 1991 issue of Scientific American. The three problems originated with mathematics professor Ross Honsberger, University of Waterloo, Canada.
   A Grecian urn contains 75 white beans and 150 black beans. Next to the urn is pile of 200 black beans.  
   Pick two beans at random from the urn.
   If both beans are black (A), place one on the pile and return the other to the urn.
   If one of the beans is black and the other bean white (B), place the black bean on the pile and drop the white bean, back into the urn.
   If both beans are white (C), discard both white beans, pick a black bean from the pile and drop it into the urn.
   No matter the color of the two beans, every time two beans are picked at random, the number of black and white beans in the urn will decrease by one.
   Question: Will there ever be just one bean in the urn and if, so, what will be its color?
   Not having a Grecian urn and a supply of black and white beans handy, I decided to write a Scratch simulation of the problem. You can view and download the Scratch program by clicking on this link.
https://scratch.mit.edu/projects/67083730/
   You can click on the green flag to run the program to find the answer to the problem. If you don't believe the result, run it again. If you still don't believe it, check my code and determine if there is a mistake in my logic.

Tuesday, May 12, 2015

Lewis Carroll's Fifth Pillow Problem

   Lewis Carroll is the pen name of Charles Dodgson (1832-1898). Dodgson was a mathematician, logician, and church deacon. He is most remembered as the author of Alice's Adventures in Wonderland and Through the Looking-Glass.
   He also wrote a book of problems called Pillow Problems. This project looks at one of those problems, a particularly tricky probability problem. Here it is.
The Fifth Pillow Problem
   A bag contains one counter, known to be either white or black. A white counter is put in, the bag shaken, and a counter drawn out, which proves to be white. What is now the chance of drawing a white counter?
   Most problem solvers quickly decide that the probability of drawing the white counter is one-half. This is wrong.
   You could of course Google Lewis Carroll’s Fifth Pillow Problem to find a derivation of the theoretical probability. Instead, examine the data from several runs of this project and form your conjecture as to the chances for drawing a white counter and then look at the theoretical solution.

   The project can be viewed and downloaded by clicking on this link.
https://scratch.mit.edu/projects/60235654/

Saturday, February 28, 2015

Triangle Triplets


   Roll three dice and imagine that the three top numbers represent ‘lengths’. Can the three lengths form a triangle? Most people, without thinking, say “yes.’ But the answer is that not all whole numbers, taken as triplets, form triangles. For example, the whole numbers 2, 3, and 6 do not form a triangle but 3, 5, and 6 do form a triangle. This is easily seen by studying the following diagram.
   This becomes an interesting programming problem. There are 216 (6 x 6 x 6) possible number triplets formed by rolling ordinary, six-sided dice. Those combinations can be checked by hand (a laborious but doable activity) but what if the dice are icosahedrons like those used in Dungeons and Dragons. That’s 8 thousand combinations!
   My Scratch project Triangle Triplets quickly computes which number triplets do form triangles for 4, 6, 8, 12, and 20-sided dice. The program also counts equilateral, scalene, and isosceles triangles for each set of three dice. Using this data one can compute the probability of the number triplets forming a triangle, an equilateral triangle, a scalene triangle, or an isosceles triangle.
   You can view and download this Scratch project by clicking on this link.
http://scratch.mit.edu/projects/48781360/
   The problem has quite a history and a copy of the mathematics underlying the problem and an annotated Scratch algorithm can be had on request by sending an email to
grandadscience@gmail.com.


Friday, May 9, 2014

Count Buffon's Needle Problem

  The foundation of probability theory was established in 1654 through a series of letters between Blaise Pascal and Pierre de Fermat. These letters traded solutions to a gambling problem raised by the Chevalier de Méré.
   Probability theory grew slowly over time. Approximately one hundred years after Pascal and Fermat solved a gambling problem, Count Buffon analyzed another gambling problem. Surprisingly, his analysis revealed  a close connection between a game involving dropping a needle onto a grid of regularly spaced lines and the number Pi (π).
   Gamblers at that time were beginning to realize that understanding the theory underlying any game would allow them to maximize winnings and minimize losses.  
   Count Buffon was born into a wealthy French family and spent his life pursuing his interests in mathematics, physics, and natural history. His love of nature led him to become curator of French Royal Gardens and Museum.
   The simplest case of Buffon’s needle problem is when the separation of the lines, L, equals the length of the needle. The question then becomes what is the probability that a needle dropped on a grid of these equally spaced lines intersects one of the lines?
   The needle problem is an early example of what we now call geometrical probability because its solution involves the ratio of two known areas.

   The project can be viewed and downloaded by clicking on the following link.
http://scratch.mit.edu/projects/21279465/
   View this short video to observe a 1000-needle run of the Buffon Needle simulation. The simulation starts by dropping a single needle three times to show you how it works and then the slider is set to 1000 needles. Check the Approximation to π window in the lower left corner when the simulation ends.

   As usual, a free PDF document describing the mathematics and Scratch programming techniques is available on request by sending an email to grandadscience@gmail.com.

Monday, April 21, 2014

Bertrand's Random Chord Paradox 1

   The Random Chord Probability Problem Scratch project described in the February 30, 2014 post stated that the project was a warm up to Bertrand's famous Random Chord Paradox.
  The random chord problem was originally posed by Joseph Bertrand in his work, Calcul des probabilités (1888). Bertrand gave three arguments, all apparently valid, yet yielding three different results.
   Given a circle with an inscribed equilateral triangle. What is the probability that a randomly selected chord is longer than the side of the triangle?
   Click on the video to see the Scratch simulation of Paradox 1 using the random endpoints method. The code selecs two random points on the circumference of the circle, draws the chord connecting the points, and compares the length of the chord to the length of the side of the equilateral triangle.


   At the beginning of the video, the Picks slider is set to one to show how the random chord appears on the circle. The slider is then set to 1000 Picks and, after 1000 random chords have been picked, the Probability Chord > Side slider shows that the experimental probability (Monte Carlo) is 0.339.
   On can reasonably conjecture that the theoretical probability is 0.333… or 1/3.
   The Bertrand's Paradox 1 Scratch project can be viewed and downloaded at the following link.
http://scratch.mit.edu/projects/20157686/
   As usual, I have written a document, Bertrand's Random Chord Paradox 1 (PDF), that describes the code used in the project and also presents a theoretical solution to the problem.  To receive a copy of this document, send an email request to grandadscience@gmail.com.