I’m making Spaghetti and Meatballs for dinner right now. I have a couple of kids that are gluten free, so I have to make two batches of noodles. We all know you can’t have too many noodles…

Anyway, Marilyn Burns tweeted a cool problem that I’d like to discuss.

I took a piece of spaghetti 1 unit long (in my head obviously) and broke it. The shorter piece is set as one of your three pieces you need to try and make a triangle out of but the longer pieces will be broken again.

I laid the short piece along the positive x-axis starting at the origin and the long piece vertically up from the end of the short piece. Note that the longest that the short piece could possibly be is 0.5 units. Here is a pic:

The next step is to figure out where you could break the red piece to actually create a triangle. The key is that no piece can be greater than 0.5 or you will not be able to complete a triangle.

The black segment shows all the places you can cut the longer piece of spaghetti so that neither piece after the cut is > 0.5. This black segment is 0.5 below the top of the red segment to 0.5 above the bottom of the red segment. Any point in the black is < 0.5 away from both ends of the long piece.

If I do this for every possible short segment I get:

The black region shows all the places where the second break with result in a triangle and the orange region shows all the places where the second break will result in not making a triangle. You can see geometrically that the probability to make a triangle is 1/3.

Some have posted that the probability is .386 based on simulations and/or calculus. In their calculations I’m seeing (1-x)/x and I can see how that is the same as what I have here… if I would have laid the long section along the x-axis… Also the black section in my graph has probability of (0.5-(0.5-x))/(1-x) which turns out to be x/(1-x) of a triangle being formed at each x-value. I would then integrate x/(1-x) on the interval 0 to 1/2 to accumulate or add up all of those probabilities. I did this and got their same answer of .386 when I multiply by 2 which is what they also did. I’m not really sure why this answer came up different than the 1/3. I feel like we should have gotten the same answer both ways.

On another note…

If, however, as some have proposed, you do not restrict it to breaking the longer piece, it doesn’t change the problem much. I put the first break along the x-axis as before and the second piece to be broken vertically as before. The difference is that now the first piece could be as big as 1 unit. As soon as the second piece is shorter than 0.5, any break on the second piece will not create a triangle.

The resulting diagram shows the new scenario:

This new probability is 1/4. Yet this one is also not really 1/4 either and following the logic below… The probability of getting a triangle for a first break of 0-0.5 is 0.38628 and the probability of getting a triangle for a first break of 0.5-1 is 0. It’s equally likely that the first cut would be between 0-0.5 and 0.5-1. So, the probability of getting a triangle with a first break from 0-1 is (0.38628+0)/2 = **.1931**

Addition:

This tweet by Simon, a couple of great comments below and some other tweets have helped to to visualize and understand better what is going on here. I’ll explain my new thoughts below.

Because each first break is equally likely, The chance that you get a triangle out of one first break should be weighted the same as the chance you get a triangle out of another first break. I’ll use two first breaks as an example:

Let’s say only two first breaks were possible. a break at 0.2 or a break at 0.4 and both were equally likely to happen.

**Here is how you would calculate the probability of getting a triangle:**

1/2 of the time I would get a break at 0.2 and the probability of getting a triangle after that is 1/4.

1/2 of the time I would get a break at 0.4 and the probability of getting a triangle after that is 2/3.

1/2 * 1/4 + 1/2 * 2/3 is 1/8 + 1/3 = 3/24 + 8/24 = **11/24**.

**Here is how you would calculate the probabilities separately and then add and average them:**

The probability of the 0.2 first break creating a triangle after the second break is 0.2/0.8 which is 1/4.

The probability of the 0.4 first break creating a triangle after the second break is 0.4/0.6 which is 2/3.

Since they are equally likely I need to add those probabilities and get 1/4 + 2/3 = 3/12 +8/12 = 11/12 and divide by 2 to average the two probabilities and I get **11/24**.

Notice that these 2 probabilities are the same.

**Here is a method of figuring out the probabilities by the total lengths which is analogous to finding the total area like I did originally above to get 1/3. **

The lengths creating a triangle for either first break is 0.2 + 0.4 =0.6

The lengths creating a triangle or not for either first break is 0.8 + 0.6 = 1.4

The probability of getting a triangle then is: (0.2+0.4)/(0.8+0.6) = 0.6/1.4 = 6/14 =3/7.

…Essentially coming down to adding 2/8 +4/6 and getting 6/14. I can’t imagine doing this with fractions and yet it seemed perfectly reasonable within this area model at the time.

So what we really need is a probability graph to find the average of.

What is the probability at each possible first break (x)?

Notice that at each x the length of the section that leads to a triangle is x and the length of the long piece is 1-x. So the probability of getting a triangle at any x is x/(1-x).

The average of all these probabilities is the integral of x/(1-x) from 0 to 0.5 divided by 0.5. This is equal to approximately **0.38628**

If you’ve somehow made it this far all the way down here…

I’ve created a similar simpler problem that I think would bridge the gap to correctly understanding how this problem works. Chances of getting a present

Advertisements

%d bloggers like this:

That’s a beaut.

Nice! Here’s my quick and dirty processing simulation: http://recursiveprocess.com/p5js/spaghetti/ and code: http://recursiveprocess.com/p5js/spaghetti/sketch.js

This is a great simulation! I love the visual. Do you get 1/4 in the simulation when you can take the second cut on either piece, or do you get another irrational decimal?

I get some other decimal (irrational?): http://recursiveprocess.com/p5js/spaghetti2/

Ratio is ~ 0.1930944

after 10,000,000 trials.

Lovely diagrams!

I got 1/3 at first too, and a diagram very like yours.

But I’ve come round to thinking that the .386 answer is correct. The problem with the diagram is that it shows possibilities, not probabilities. So we can’t just say that the probability is the area of the black spaghetti divided by the total area of spaghetti.

To look at probabilities we have to scale those individual spaghettis up or down so they’re all the same length, because the probability of the original break being in any place is the same, and this should be reflected in equal length of the lines. (No line should be “weighted” in any way.)

This is what the /x is doing in the (1-x)/x: it’s scaling all the spaghetti lines to be the same length. You haven’t divided by x in your diagram.

If you do this, your black triangle, which also gets scaled by the same amount, becomes a curved shape.

And the area of that new shape is not 1/3 of the total spaghetti area any more, it’s .386 of the total spaghetti area.

Because I’ve forgotten lots of my calculus (!) I’ve had to take the integration on trust, but I can see that the figure should be a little bigger than 1/3 because the longer black lines get scaled down less than the shorter ones.)

What a great explanation of why it wouldn’t be 1/3 and why we have to take the probabilities at each break 1st before adding them all up. Thanks!

Pingback: Chances of getting a present! | To Accumulate a Rate --- Integrate!