UKC

Maths teaser

New Topic
This topic has been archived, and won't accept reply postings.
 Philip 25 Aug 2017
I was bored cooking rice for dinner and came up with this. You need the answer and the most elegant proof (it's simple enough to do long hand)

Cooking rice for 4 with 5 cardamom pods in.
When I serve 4 equal portions of all the rice, what are the odds we each get at least one cardamom pod.

Or simply, what is the probability of getting any arrangement of 2 1 1 1 across 4 boxes filled with 5 items.
In reply to Philip:
Oh No - Statistics - My Dark Side of Maths!
 Dave the Rave 25 Aug 2017
In reply to Philip:

Depends if you have your eyes open?
 john arran 25 Aug 2017
In reply to Philip:

Your 2 versions of the question aren't quite the same, since they would differ in the case of , e.g. a 3,1,1,0 split.

The chance of Person A not getting pod 1 is 3/4, so of Person A not getting any pod is (3/4)^5 = 243/1024
The chance of Person A getting at least one pod is therefore 781/1024
Since there are 4 people, the chance of all of them getting at least one pod is therefore (781/1024)^4 = roughly 0.338, so there's roughly 0.662 chance that at least one person will not get a pod. The chance of there being exactly one person without a pod would be slightly lower than that.

note: this is probably wrong as it's 3 beers into the evening!
 Robert Durran 25 Aug 2017
In reply to john arran:

> Your 2 versions of the question aren't quite the same, since they would differ in the case of , e.g. a 3,1,1,0 split.

Not sure what you mean by this. It seems to me the two problems are the same.

> The chance of Person A not getting pod 1 is 3/4, so of Person A not getting any pod is (3/4)^5 = 243/1024. The chance of Person A getting at least one pod is therefore 781/1024. Since there are 4 people, the chance of all of them getting at least one pod is therefore (781/1024)^4

I don't think this is right because the events that each person gets at least one pod are not independent.
 Ian W 25 Aug 2017
In reply to john arran:

You've just come upwith the mst compicated way i could think of to admit defeat.
As I'm in a worse state than you, beeing 3 large cocktails to the better in a hotel in the UAE, I'm not even going to try, despite my PGCE secondary maths quali.
Anyhoo, its not that complicated probability, and not that difficult whwn sober.
 Robert Durran 25 Aug 2017
In reply to Philip:

I think the answer is 15/64. I'll try to come up with a not too technical explanation.
 john arran 25 Aug 2017
In reply to Robert Durran:

> Not sure what you mean by this. It seems to me the two problems are the same.

On reflection, I agree.

> I don't think this is right because the events that each person gets at least one pod are not independent.

Ok, another try:
There are 4^5 = 1024 combinations of allocating 5 pods to 4 people
There are 3^5 = 243 combinations of allocating 5 pods to 3 people
There are 2^5 = 32 combinations of allocating 5 pods to 2 people
There is 1^5 = 1 combination of allocating 5 pods to 1 person

Therefore there are 243+32+1 combinations out of 1024 in which not everyone gets a pod, which is approx 0.27, so approx 0.73 chance that everyone will get at least one pod.
 john arran 25 Aug 2017
In reply to Ian W:

> As I'm in a worse state than you, being 3 large cocktails to the better in a hotel in the UAE,

I'll see your hotel in UAE, and raise you a UN compound in Mogadishu!
 BusyLizzie 25 Aug 2017
In reply to Philip:

I'm sorry, you have to make this work manually. The consequences (if your family is anything like mine) of anyone not getting a cardamom pod are so terrible that you cannot leave it to chance.
OP Philip 25 Aug 2017
In reply to Philip:

My first route was, possible arrangements:
2111
2210
3110
3200
4100
5000

And those can occur in different number of ways, which in that order are 4, 12, 12, 12, 12, 4

Eg 2111,1211,1121,1112
And 3200,3020,3002,2300,0320,0302...

So I think 4 in 56 or 1 in 14.

But that seemed messy.

OP Philip 25 Aug 2017
In reply to BusyLizzie:

> I'm sorry, you have to make this work manually. The consequences (if your family is anything like mine) of anyone not getting a cardamom pod are so terrible that you cannot leave it to chance.

4 came out before serving, only one person got one in the end. Didn't see that coming.
 Robert Durran 25 Aug 2017
In reply to Philip:

> My first route was, possible arrangements:
> 2111
> 2210
> 3110
> 3200
> 4100
> 5000

> ..........So I think 4 in 56 or 1 in 14.

But some arrangements are more likely than others (Just like, if you have two children, a boy and a girl is more likely than two boys. Equivalent to putting two items into two boxes: 1,1 is twice as likely as 2,0 or 0,2)
Lusk 25 Aug 2017
In reply to Philip:

cardamom pods

Black or green?
Green will be less conspicuous in white rice, which might affect the randomness when plunging the spoon in for serving.
But those black beauties, well, depends on who you like ...
 Robert Durran 25 Aug 2017
In reply to Robert Durran:

> I think the answer is 15/64. I'll try to come up with a not too technical explanation.

I have now arrived at the same answer by a different approach and am sure it is correct. Not easy to explain here though.
 john arran 25 Aug 2017
In reply to Robert Durran:

> I have now arrived at the same answer by a different approach and am sure it is correct. Not easy to explain here though.

If your middle name is Fermat, I'd be quite worried at this point!
 elsewhere 25 Aug 2017
In reply to Philip:
Based on 4 million meals for four persons
Approximately 23.49+-0.02%

Outputs 4 million meals for four persons in batches of 1 million meals
999999 765675 234325
999999 764734 235266
999999 765279 234721
999999 764856 235144
Post edited at 22:09
 elsewhere 25 Aug 2017
In reply to Philip:
import random
fail = 0
success = 0
for x in xrange(1000000):
||||distribution = [0,0,0,0]
||||for seeds in range(5):
||||||||portion = random.randint(0,3)
||||||||distribution[portion] += 1
||||if max(distribution) > 2 or min(distribution) <1:
||||||||fail += 1
||||||||#print x, fail, success, distribution, " fail"
||||else:
||||||||success += 1
||||||||#print x, fail, success, distribution, " success"
||||
print x, fail, success


It's Python 2 so replace |||| with a tab or other consistent indentation as UKC doesn't preserve indentation
Post edited at 22:11
 Robert Durran 25 Aug 2017
In reply to elsewhere:

> Based on 4 million meals for four persons

> Approximately 23.49+-0.02%

15/64=0.234375, so not actually within 0.02%.........
OP Philip 25 Aug 2017
In reply to Robert Durran:
> But some arrangements are more likely than others (Just like, if you have two children, a boy and a girl is more likely than two boys. Equivalent to putting two items into two boxes: 1,1 is twice as likely as 2,0 or 0,2)

You cut out my text, in your reply, that stated that. There are only 4 ways to serve all 5 one plate, but 12 ways to serve 2 2 1 0 which 6 ways of having 2 and then for each of those 2 options for which plate has the 1.

As there are only 4 ways for everyone to get at least 1, that is 1 each and the 5th going on any of 4 I don't see how the probability can be anything but 4 in X, so 15 in 64 seems wrong.
Post edited at 23:47
1
OP Philip 25 Aug 2017
In reply to Philip:

I've got it now, my answer is right, and the best answer uses this: https://math.stackexchange.com/questions/192670/n-unlabelled-balls-in-m-lab...

That confirms that the number of arrangements is 56, and it's clear that only 4 exist that meet my original criteria. I expected it to be unlikely, but ~7% was lower than I expected.
1
 Robert Durran 25 Aug 2017
In reply to Philip:

> You cut out the text in your reply that stated that. There are only 4 ways to serve all 5 one plate, but 12 ways to serve 2 2 1 0 which 6 ways of having 2 and then for each of those 2 options for which plate has the 1.

That is not the sense in which I meant that some arrangements are more likely than others. The arrangement 2,1,1,1 in that order is more likely than, say, 5,0,0,0 in that order. This is because for 5,0,0,0 every item has to go into the first box without choice whereas for 2,1,1,1 the first item, for instance, could go into any box.

It should become obvious if you think about the case of 2 items and 2 boxes, The probability of 2,0 is 1/2x1/2=1/4 whereas the probability of 1,1 is 1/4 +1/4=1/2 (the boxes can be filled in either order).

 elsewhere 26 Aug 2017
In reply to Robert Durran:

so you may be wrong
 Robert Durran 26 Aug 2017
In reply to Philip:

> I've got it now, my answer is right, and the best answer uses this: https://math.stackexchange.com/questions/192670/n-unlabelled-balls-in-m-lab...

But that doesn't take into account the fact that there are more ways of getting some distributions than others (as I explained in my last post). The added note explains that this is the case but that it is not relevant to the question being asked - they are simply counting distributions, not how likely they are if the items are assigned at random to boxes.
 Robert Durran 26 Aug 2017
In reply to elsewhere:

> so you may be wrong

I which case your simulation which agreed with my answer of 15/64 would also be wrong!
 elsewhere 26 Aug 2017
In reply to Robert Durran:

Std Dev only agrees with the "right answer" 2/3rds of the time?
 bouldery bits 26 Aug 2017
In reply to Philip:
In my experience, there is a zero percent chance as I always get all the pods.
Post edited at 00:33
 Robert Durran 26 Aug 2017
In reply to elsewhere:

> Std Dev only agrees with the "right answer" 2/3rds of the time?

Not sure what you mean by that. Your simulation agreed well with my answer - I don't think we have anything to disagree about!
 elsewhere 26 Aug 2017
In reply to Robert Durran:
ten million meals for four
7655145 2344855

getting closer
 John Gillott 26 Aug 2017
In reply to Robert Durran:
I'm also getting 15/64, via the basic probability tree method:

4 urns 5 balls.

First ball goes anywhere. Then we have the following paths to success:

1. same, different, different, different = 1/4 x 3/4 x 2/4 x 1/4 = 6/256
2. different, same, different, different = 3/4 x 2/4 x 2/4 x 1/4 = 12/256
3. different, different, same, different = 3/4 x 2/4 x 3/4 x1/4 = 18/256
4. different, different, different, same = 3/4 x 2/4 x 1/4 x 4/4 = 24/256

Add them up and we have 60/256 = 15/64
Post edited at 01:04
 john arran 26 Aug 2017
In reply to Robert Durran:
Couldn't sleep, and must've sobered up a little because I now get the same answer as you!

I reasoned by decision tree, assigning one pod to a person at each stage. At any stage the distribution of pods can be represented numerically, e.g. 2110 means 1 person has 2 pods, 2 people have 1 pod, 1 person has no pods. Ordering is irrelevant.
There are only 4 success paths, which are:
1000 - 2000 - 2100 - 2110 - 2111 (i.e. double-pod is assigned at stage 2)
1000 - 1100 - 2100 - 2110 - 2111 (i.e. double-pod is assigned at stage 3)
1000 - 1100 - 1110 - 2110 - 2111 (i.e. double-pod is assigned at stage 4)
1000 - 1100 - 1110 - 1111 - 2111 (i.e. double-pod is assigned at stage 5)

Probability of each path is then:

1000 - 2000 - 2100 - 2110 - 2111 (i.e. double-pod is assigned at stage 2)
1 x 1/4 x 3/4 x 2/4 x 1/4 = 6/256

1000 - 1100 - 2100 - 2110 - 2111 (i.e. double-pod is assigned at stage 3)
1 x 3/4 x 2/4 x 2/4 x 1/4 = 12/256

1000 - 1100 - 1110 - 2110 - 2111 (i.e. double-pod is assigned at stage 4)
1 x 3/4 x 2/4 x 3/4 x 1/4 = 18/256

1000 - 1100 - 1110 - 1111 - 2111 (i.e. double-pod is assigned at stage 5)
1 x 3/4 x 2/4 x 1/4 x 4/4 = 24/256

Chance of any of these happening is the sum (6+12+18+24)/256 = 60/256 = 15/64

edit: damn, too slow - but satisfying nonetheless!
Post edited at 01:39
 Ian W 26 Aug 2017
In reply to john arran:

Nah, you're ok. Hilton Al Hamra will suffice........(its very nice, and those cocktails were indeed pretty decent....)
 mbh 26 Aug 2017
In reply to Philip:

Does anyone here do Project Euler https://projecteuler.net?

I find it absorbing and dangerously time consuming. There are by now over 600 problems that normally require both coding and insight to solve in a reasonable time. Many of the problems concern probability or number theory, but also network analysis. Some are easy, most are not. You can code in any language.

Once you have solved a problem, you have access to the forum for that problem where, more often than not, you discover really elegant ways to solve it.
 Robert Durran 26 Aug 2017
In reply to John Gillott:

That's how I did it.

My other method just counted the number of ways of putting the items into the boxes to get a favourable distribution then divide by the total number of ways:
(5C2 x 6 x 4)/(4^5)
 rlrs 26 Aug 2017
 Robert Durran 26 Aug 2017
In reply to john arran:

So the same method as me and John!
 Robert Durran 26 Aug 2017
In reply to Philip:

The obvious question is how to generalise to x people with y cardamom pods. Easy enough when there is one more pod than people.......
 Robert Durran 26 Aug 2017
In reply to john arran:

> The chance of Person A not getting pod 1 is 3/4, so of Person A not getting any pod is (3/4)^5 = 243/1024 ...........

Here is a third method which takes this as a starting point but continues correctly! A bit more technical, though using a fairly standard result - a generalisation of P(A or B)=P(A) + P(B) - P(A and B) to any number of events, in this case the four events that each person gets no cardamon pods.

4C1 x (3/4)^5 - 4C2 x (2/4)^5 +4C3 x (1/4)^5 = 49/64
This is the probability that at least one person gets no cardamon pods, so subtract from 1 to get 15/64

And this method will generalise to any number of people and any number of cardamon pods!
 JRJones 26 Aug 2017
In reply to Philip:

4/56

i was bored so i wrote out all 56 combinations
1
 john arran 26 Aug 2017
In reply to Robert Durran:

Nice one Robert. I definitely knew where I wanted to go, but last night my ... ahem! ...'impaired' grey matter wouldn't let me see where I was going wrong in getting there!
 John Gillott 26 Aug 2017
In reply to john arran:

Here's an easier one, but it's quite a nice one I think:

What is the chance that the six balls selected in the UK Lottery, from balls numbered 1 - 50, will be selected in strict ascending order? (I think that's the UK Lottery, it doesn't matter for our purposes if it isn't).

For example, 5, 25, 34, 35, 36, 50 drawn in that order would count as success.
 Robert Durran 26 Aug 2017
In reply to John Gillott:

Is that not just 1/720 ?
1
 John Gillott 26 Aug 2017
In reply to Robert Durran:

It is - I did say it was easier. I've seen people go into all kinds of calculations to try to crack it, but the key is to see how it is in fact the same as 6 balls from 6, appearing in order - the pool from which they are drawn makes no difference.
 john arran 26 Aug 2017
In reply to John Gillott:

Definitely easier, although it could easily appear otherwise if seduced down the road of doom!
 Brass Nipples 26 Aug 2017
In reply to Philip:


Don't forget you may have 5 cardoman pods left in the pan when all the rice is served up. It affects the odds.
 Robert Durran 26 Aug 2017
In reply to john arran:

> Definitely easier, although it could easily appear otherwise if seduced down the road of doom!

I took one quick look down the road of doom and recoiled in horror.
 birdie num num 26 Aug 2017
In reply to Philip:

Is it a Nigella recipe?
 Pero 27 Aug 2017
In reply to Philip:

Another approach to the original problem is to look at where each pod goes. If we label the pods 1-5 and the people A-D then there are 4^5 = 1024 arrangements of pods to people.

We need one person to get 2 pods and the others to get one each. We can calculate how many ways person A gets 2 pods then multiply this by 4 to cover the cases where B,C or D gets the two pods.

There are 5-choose-2 = 10 options for the two pods that A gets then 3x2x1 =6 options for the remaining three people to get one pod each.

So, there are 60 ways A can get the two pods, hence 240 ways that anyone can get the two pods (and the rest one pod each).

And 240/1024 = 15/64.
 Robert Durran 27 Aug 2017
In reply to Pero:

That is the same way I mentioned at 9.10am yesterday. Definitely arithmetically simplest.
 Pero 27 Aug 2017
In reply to Robert Durran:

> That is the same way I mentioned at 9.10am yesterday. Definitely arithmetically simplest.

Yes, I see that now. Yours was so concise that I missed it.
 Robert Durran 27 Aug 2017
In reply to Pero:

> Yes, I see that now. Yours was so concise that I missed it.

More that I couldn't be bothered with a full explanation!

New Topic
This topic has been archived, and won't accept reply postings.
Loading Notifications...