Lucky socks

Lucky socks

Posers and Puzzles

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.

AP

Joined
29 Jul 08
Moves
1570
19 Feb 11

Roma, there is a big difference between coin tosses and sock choices, namely the coin is replaced between each toss while the sock (we hope) goes into the laundry and not back into the drawer. This makes the odds during each coin toss independent of previous coin tosses, while the odds during each sock choice depend on what happened before.

Since you brought up a gambling analogy, think of this problem as counting cards in Black Jack not tossing a coin. If you remember some fact about the cards in the deck that you've already seen, this information will help you refine the probabilities of which cards you are likely to get in the future. Even remembering a minor and non-specific detail can have an impact on your ability to predict the probabilities of future cards dealt.

st johnstone

Joined
14 Nov 09
Moves
417367
19 Feb 11

Originally posted by Arctic Penguin
Roma, there is a big difference between coin tosses and sock choices, namely the coin is replaced between each toss while the sock (we hope) goes into the laundry and not back into the drawer. This makes the odds during each coin toss independent of previous coin tosses, while the odds during each sock choice depend on what happened before.

Since y ...[text shortened]... c detail can have an impact on your ability to predict the probabilities of future cards dealt.
see where both of you are coming from, but in this case we dont know any of the previous 4 days results, if he was right once or twice it would change the odds but as the problem stands none of the previous days socks are known to us apart from all wrong, so it has to be 20% chance. as to card counting, i wish i had a brother like dustin hoffman, cant be compared as we dont know what socks(cards) that have previously been choosen. on a more serious note why does he only have 5 pairs does he go barefoot at the weekend?

Joined
18 Jan 07
Moves
12469
19 Feb 11

Originally posted by roma45
see where both of you are coming from,
No, you don't, because:

but in this case we dont know any of the previous 4 days results,

...but we do know something about those days. We know, to name but a trivial example, that the possibility of MTWR F can be discounted completely, even if RWTM F cannot. We don't know everything about the previous 4 days, but we know just enough to make the odds less than 1 in 5.

And if you still don't believe it... just write down all possibilities and count them. Don't trust your instincts; human instincts on probabilities have been proven wildly wrong before. Count the buggers.

on a more serious note why does he only have 5 pairs does he go barefoot at the weekend?

Isn't it obvious? On weekends he wears sandals with plain white socks, instead of his workday loafers over black socks with the day on them.

Richard

st johnstone

Joined
14 Nov 09
Moves
417367
19 Feb 11

Originally posted by Shallow Blue
No, you don't, because:

[b] but in this case we dont know any of the previous 4 days results,


...but we do know something about those days. We know, to name but a trivial example, that the possibility of MTWR F can be discounted completely, even if RWTM F cannot. We don't know everything about the previous 4 days, but we know [i]just en ...[text shortened]... ite socks, instead of his workday loafers over black socks with the day on them.

Richard[/b]
so whats the odds of being wrong on a monday? 20% same must apply to every day of the week then 5 times 20% = 100%. if friday is only 18% how can it add up? nothing wrong with white socks and sandals. lol

Quiz Master

RHP Arms

Joined
09 Jun 07
Moves
48793
20 Feb 11

Originally posted by roma45
so whats the odds of being wrong on a monday? 20% same must apply to every day of the week then 5 times 20% = 100%. if friday is only 18% how can it add up? nothing wrong with white socks and sandals. lol
It doesnt have to add up!

LJ and AP are quite correct.

It is counter-intuitive that getting the socks wrong each day increases the odds of getting it wrong on Friday - thats why I posted the problem here!

btw: brown socks at the weekend - I dress casual. :-)

AP

Joined
29 Jul 08
Moves
1570
20 Feb 11
7 edits

What you're thinking of, roma, is that the sock probabilities for what you get on Friday will add up to 1. With the information we have, the probability of each sock being left for Friday will be:

Monday Sock = 11/53, Tuesday Sock = 11/53, Wednesday Sock = 11/53, Thursday Sock = 11/53, Friday Sock = 9/53, TOTAL = 53/53 = 1


I'll try formalizing the N problem later if it is still unsolved, wolfgang.

P
Upward Spiral

Halfway

Joined
02 Aug 04
Moves
8702
21 Feb 11

Originally posted by roma45
so whats the odds of being wrong on a monday? 20% same must apply to every day of the week then 5 times 20% = 100%. if friday is only 18% how can it add up? nothing wrong with white socks and sandals. lol
20% applies to the unconditional probability of any day being wrong. But here you are conditioning on the previous four days being wrong, so Mr. Bayes tells you that you need to factor that information.

Here's an example where you can see how it works for Tuesday.

P(Wrong M) = 0.8

P(Lucky Tu|Wrong M) = P(Wrong M AND Lucky Tu) /P(Wrong M) = (1/5*0 + 3/5*1/4)/0.8

1/5*0: If on M he wore Tu then it's sure that Tu cannot be lucky.
3/5*1/4: If on M he wore M,Th or Fr then he has a 1 in 4 chance of being lucky on Tu

So P(lucky Tu|wrong M) is 0.1875 which is smaller than 0.2

The intuition why it's less is that since Monday was wrong that could be because you wore Tu on M. If you still think it should be 0.2, think about the P(lucky Tu|lucky M). It's obviously 1/4, right? But that's 0.25>0.2! So the P(lucky Tu|unlucky M) must be smaller than 0.2 or the unconditional probability of lucky Tu would not sum to 0.2.

Joined
26 Apr 03
Moves
26771
22 Feb 11
7 edits

Originally posted by Palynka
20% applies to the unconditional probability of any day being wrong. But here you are conditioning on the previous four days being wrong, so Mr. Bayes tells you that you need to factor that information.

Here's an example where you can see how it works for Tuesday.

P(Wrong M) = 0.8

P(Lucky Tu|Wrong M) = P(Wrong M AND Lucky Tu) /P(Wrong M) = (1/5*0 + must be smaller than 0.2 or the unconditional probability of lucky Tu would not sum to 0.2.
It all depends on the number of ways that the Socks for Monday..Thursday can be worn on the days Monday..Thursday with none of them being in the right place.

Let us say that this is Num_wrong(Days) where Days is the number of Days that the socks have to be wrong on.

We can see that:
Num_wrong(1) = 0: if there is only 1 day and one sock we can't get it wrong.
Num_wrong(2) = 1: If we have 2 days and 2 socks, one way is the wrong round and the other way both are right.
Num_Wrong(3) = 2 If we have socks abc then the wrong combos are bca, cab


To solve for the value of N days, we observe that for each sock Monday..Thursday there is one and only one day it cannot be worn.

So say Mondays sock is worn on day D, now consider where day D's sock is worn.

Each sock D can be worn on (N-1) different days.
If it is worn on Monday we are reduced to N-2 remaining socks, each of which cannot be worn on one day out of N-2, which is Num_Wrong(N-2)
If it is not worn on Monday then it is a member of a group of N-1 remaining socks, each of which cannot be worn on one day out of N-1, which is Num_Wrong(N-1)

Putting this together:

Num_Wrong(N) = (n-1)*(Num_wrong(N-2) + Num_Wrong(N-1))

So Num_Wrong(4) = 3*(1 + 2) = 9

The total number of arrangements of 5 socks is 5!, so the probability of getting only fridays socks right is

9/(5*4*3*2)= 3/40

Note that I get 9 and not 11 (which is what lemonjello got) I think this is because his list of "all wrong" combos:
TMRW
TWMR
TWRM
TRMW
WMTR
WMRT
WRMT
WRTM
RMTW
RWMT
RWTM
includes TWMR and WMTR, which have Thursday's sock on Thursday (Thursday is R)

Does everyone think this is right? If so, it can be extended to larger numbers of days.

AP

Joined
29 Jul 08
Moves
1570
23 Feb 11
4 edits

Originally posted by iamatiger
Note that I get 9 and not 11 (which is what lemonjello got) I think this is because his list of "all wrong" combos:
TMRW
TWMR
TWRM
TRMW
WMTR
WMRT
WRMT
WRTM
RMTW
RWMT
RWTM
includes TWMR and WMTR, which have Thursday's sock on Thursday (Thursday is R)
Well, that was for the four day problem where you are looking for a match on Thursday with no matches on MTW and not the five day one where you can't have a match on Thursday either. Those were the two successes for what you call Num_Wrong(3).

Joined
26 Apr 03
Moves
26771
23 Feb 11
1 edit

Originally posted by Arctic Penguin
Well, that was for the four day problem where you are looking for a match on Thursday with no matches on MTW and not the five day one where you can't have a match on Thursday either. Those were the two successes for what you call Num_Wrong(3).
Ok, was I right or wrong though? Didn't you say the probability was 9/53? I got 3/40....

Joined
26 Apr 03
Moves
26771
23 Feb 11

Originally posted by roma45
see where both of you are coming from, but in this case we dont know any of the previous 4 days results, if he was right once or twice it would change the odds but as the problem stands none of the previous days socks are known to us apart from all wrong, so it has to be 20% chance. as to card counting, i wish i had a brother like dustin hoffman, cant be comp ...[text shortened]... hoosen. on a more serious note why does he only have 5 pairs does he go barefoot at the weekend?
Look at it this way.

I have two days Monday and Tuesday, 2 corresponding pairs of socks, and I wear the wrong pair of socks on Monday, what is the probability of wearing the right pair of socks on Tuesday? Is it still 50%?

AP

Joined
29 Jul 08
Moves
1570
24 Feb 11
12 edits

iamtiger you pretty much nailed the general formula, but you were just missing the probability part. n! can't be the denominator, because then you'd be counting all arrangements of socks while we want to count only arrangements of socks where the first n-1 socks have no matches but the nth sock can have a match (a counted success) or not (a counted failure). We can also quickly check that 9/120 for Friday isn't a valid answer because it would leave 111 possibilities to be divided evenly between the other four possible socks on Friday which would require 27.75/120 odds of getting either M, W, T, or R on Friday to maintain symmetry and 27.75 is not a whole number.


f(n) is a function that counts how many are wrong for n days (the same as your Num_Wrong function). The actual probability for the sock problem is p(n) where n is the number of days. I am pretty sure your f(n) function is perfect, so here it is again exactly as iamtiger described it:

f(n)=(n-1)*[f(n-2)+f(n-1)] where f(n) is a function that counts the number of ways of rearranging n labeled socks with no matches to the day of the week.

From here we have to acknowledge that the number of ways of rearranging n socks such that the only match is on the last day is the same as the number of ways of rearranging n-1 socks with no matches at all (in other words f(n-1) is both the number of ways of rearranging n-1 socks to have no matches AND the number of ways of rearranging n socks to have only a match on the nth day). Once we accept this, it follows that to get the probability we simply take the number of socks that match ONLY on the nth day (which is f(n-1)) and divide by the number of socks that match on none of the n days (which is f(n)) PLUS the number of socks that match on ONLY the nth day (which is f(n-1)).

p(n)=f(n-1)/[f(n-1)+f(n)] where p(n) is the probability of getting a match on the last day of the week given mismatches on all the previous days of the week.

We can show that this formula works for the first cases:

f(1) = 0
p(1) = Not defined as there is no such problem for a 1 day week.

f(2) = 1
p(2) = f(1)/[f(2)+f(1)] = 0/(1+0) = 0/1

f(3) = 2*[f(1) + f2)]
f(3) = 2*(0+1) = 2
p(3) = f(2)/[f(3)+f(2)] = 1/(2+1) = 1/3

f(4) = 3*[f(2) + f(3)]
f(4) = 3*(1+2) = 9
p(4) = f(3)/[f(4)+f(3)] = 2/(9+2) = 2/11 (The answer to the version I did by brute force)

f(5) = 4*[f(3) + f(4)]
f(5) = 4*(2+9) = 44
p(5) = f(4)/[f(5)+f(4)] = 9/(44+9) = 9/53 (The answer to wolfgang's version)

f(6) = 5*[f(4) + f(5)]
f(6) = 5*(9+44) = 265
p(6) = f(5)/[f(6)+f(5)] = 44/(265+44) = 44/309 (I verified this one with a computer just to be extra certain)


Looks good so far... I think we've got it! Now we have a recursive formula:
f(n)=(n-1)*[f(n-2)+f(n-1)]
p(n)=f(n-1)/[f(n-1)+f(n)]

st johnstone

Joined
14 Nov 09
Moves
417367
24 Feb 11

Originally posted by Arctic Penguin
iamtiger you pretty much nailed the general formula, but you were just missing the probability part. n! can't be the denominator, because then you'd be counting all arrangements of socks while we want to count only arrangements of socks where the first n-1 socks have no matches but the nth sock can have a match (a counted success) or not (a counted fa ...[text shortened]... e a recursive formula:
[b]f(n)=(n-1)*[f(n-2)+f(n-1)]

p(n)=f(n-1)/[f(n-1)+f(n)][/b]
how about he folds his socks with the name of the week on the OUTSIDE, then he will be right every day🙂 seriously good problem finally see it thanks to ap.

Joined
26 Apr 03
Moves
26771
01 Mar 11
1 edit

I did a google search for this kind of problem, f(n) turned out to be called the number of derangements in the world of probability, represented as !n

The wikipedia page on that: http://en.wikipedia.org/wiki/Derangement
gives the weird equation:

f(n) = round(n!/e)

where round rounds to the nearest integer

seeing as p(n) = f(n-1)/(f(n-1) + f(n))

this suggests that p(n) ~ (n-1)!/(n! + (n-1)!)

A quick spreadsheet test shows this is a very good approximation for 5 days and over.

Quiz Master

RHP Arms

Joined
09 Jun 07
Moves
48793
04 Mar 11

Originally posted by iamatiger
I did a google search for this kind of problem, f(n) turned out to be called the number of derangements in the world of probability, represented as !n

The wikipedia page on that: http://en.wikipedia.org/wiki/Derangement
gives the weird equation:

f(n) = round(n!/e)

where round rounds to the nearest integer

seeing as p(n) = f(n-1)/(f(n-1 ...[text shortened]... (n-1)!)

A quick spreadsheet test shows this is a very good approximation for 5 days and over.
complicated solution to a "simple" problem. Well done iamatiger!

I found probability/statistics boring at Uni ... I wish I had paid more attention because its fascinating for me now.