#ThisWeeksFiddler, 20260508

This week the #puzzle is: Can You Drink the “Random-ade”? #MonteCarlo #coding #probabilities

I’m preparing a mixture of “random-ade” using a large, empty pitcher and two 12-ounce glasses.
First, I fill one glass with some amount of lemon juice chosen randomly and uniformly between 0 and 12 ounces. I fill the other glass with some amount of water, also chosen randomly and uniformly between 0 and 12 ounces. Next, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.
At this point, I refill that empty glass with yet another random amount of the same liquid it previously contained. Once again, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.
On average, how much random-ade can I expect to prepare? (Note that all three random amounts in this problem are chosen independently of each other.)

And for extra credit:

Once again I’m preparing random-ade, but this time I have three 12-ounce glasses.
I fill the first glass with a random amount of lemon juice, the second glass with a random amount of lime juice, and the third glass with a random amount of water. As before, each amount is chosen uniformly between 0 and 12 ounces, and all amounts are independent. Next, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.
At this point, I refill that empty glass with yet another random amount of the same liquid it previously contained. Once again, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.
Then I refill that now-empty glass with yet another random amount of the same liquid it previously contained. Again, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.
On average, how much random-ade can I expect to prepare?

Can You Drink the “Random-ade”?

Solution, possibly incorrect:

Program

Method 1, sanity check.

  • If the random amounts are small, then a small amount gets into the pitcher, at the lowest 0.
  • If the random amounts are all in the middle, we get 2 * 6 + 2 * 0 = 12.
  • If the random amounts are large, we get 2 * 12 + 2 * 12 = 48.
  • We expect somewhere in between 0 and 48, tending towards 12.

Method 2, Monte Carlo:

Fiddler?  True. 10000000 loops. Amount of randomade, average: 14.00286

Method 3, probabilities, integral etc. Oh my. I don’t dare go that way. Especially not when Monte Carlo is so easy.

Let’s say 14.00.

And for extra credit:

Method 1, sanity check.

  • 0.
  • 3 * 6 + 3 * 0 + 3 * 0 = 18.
  • 3 * 12 + 3 * 12 + 3 * 12 = 108.
  • We expect somewhere in between 0 and 108, tending towards 18.

Method 2, Monte Carlo:

Fiddler? False. 10000000 loops. Amount of randomade, average: 22.20186

Let’s say 22.20.

Skriv en kommentar