SPUG: Stick Riddle

Damian Conway damian at conway.org
Wed Jan 1 19:48:45 CST 2003


Brian Hatch wrote:
> 
> In his college course, he came up with the answer of 50% probability. I 
> wrote the attached Perl script to simulate this, and constently get 38%, 
> assuming the second split is done on the larger piece.
> 
> 
> Don't make assumptions.  Instead, use rand to generate two numbers
> between 0 and 100, and have those be the 'break points'.

That set of assumptions (there are *always* assumptions) yields a
probability around 25%.

Another approach would be: "randomly" break the stick once, "randomly" choose one
of the two pieces, then "randomly" break that piece again. That approach yields
a probability around 19%.

All this means is that the problem is ill-defined, particularly the word
"randomly".

In reality, to break a stick into three, you break it once and most
probably break the bigger half again. But sticks don't break uniformly
along their length. They are vastly more likely to break around the
middle of the stick, where the shear forces imparted by the moment
applied at the ends is greatest.

If the likely point of breakage where normally distributed across the
length of the stick (it wouldn't be, but it's a reasonable approximation),
then the probability of forming a triangle in the way described in
the previous paragraph is given by:

     sub norm_rand {
         my $norm = 0;
         for (1..8) { $norm += rand() }
         return $norm / 8;
     }

     foreach (0 .. 100_000) {

         # Break stick in two...
         my $break_at = norm_rand();
         my @piece = sort { $a <=> $b } ($break_at, 1-$break_at);

         # Break bigger piece in two...
         $break_at = norm_rand();
         @piece[1,2] = ($piece[1]*$break_at, $piece[1]*(1-$break_at));

         # Do they form a triangle?
         @piece = sort { $a <=> $b } @piece;
         $total_tris++ if $piece[2] < $piece[1] + $piece[0];
         $total_tries++;
     }

     print "Percent that made triangles: ", $total_tris/$total_tries * 100;

and the probability is around 99.93% (!)

So it depends entirely on how you interpret the question. Which means
that, if we truly make no assumptions, then all we can deduce is that
either the pieces do form a triangle, or they don't. Hence the
probablity is exactly 50%. Q.E.D. ;-)

Damian


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list