Page 1 of 2

Socks

Posted: August 5th, 2020, 1:03 pm
by cinelli
I own only black and white socks and all are in the wash except for four. The probability of withdrawing two at random and finding a white pair is 1/2. What is the probability of withdrawing two black socks instead?

Cinelli

Re: Socks

Posted: August 5th, 2020, 1:27 pm
by bluedonkey
cinelli wrote:I own only black and white socks and all are in the wash except for four. The probability of withdrawing two at random and finding a white pair is 1/2. What is the probability of withdrawing two black socks instead?

Cinelli

Zero. There are 3 white socks and 1 black.

n/4 * (n-1)/3 = 0.5
where n = number of white socks.

Re: Socks

Posted: August 6th, 2020, 8:37 am
by malkymoo
Or, if you don't like equations:

If there are 4 socks A B C D, the 6 possible combinations are AB, AC, AD, BC, BD, CD

If sock A only is black, then BC, BD, CD are white pairs, half of the total possible combinations.

If A is the only black sock, there cannot be a black pair.

Re: Socks

Posted: August 6th, 2020, 9:54 am
by cinelli
Well solved both. You didn't fall into the trap of saying that if the probability of a white pair is 1/2, the same must be true of a black pair.

Cinelli

Re: Socks

Posted: August 6th, 2020, 11:41 am
by UncleEbenezer
Methinks the level of your 'trap' may not be quite that of regulars here.

Still, now if we ever meet in person, I shall know you by the zebra-striped socks.

Re: Socks

Posted: August 6th, 2020, 12:05 pm
by jfgw
bluedonkey wrote:Zero. There are 3 white socks and 1 black.


There could be two long white socks and two short white socks. The answer is still zero, however.

If you are not careful when you wash them, you could end up with some grey socks.

I have a nephew who always buys the same type of navy blue socks so that he doesn't have to sort them into pairs.


Julian F. G. W.

Re: Socks

Posted: August 6th, 2020, 2:18 pm
by UncleEbenezer
jfgw wrote:I have a nephew who always buys the same type of navy blue socks so that he doesn't have to sort them into pairs.
Julian F. G. W.


Does he sort the holy from the wholly unholy?

What about holes in different places: for instance the toe vs under the ball of the foot?

Re: Socks

Posted: August 6th, 2020, 2:45 pm
by ReformedCharacter
UncleEbenezer wrote:
jfgw wrote:I have a nephew who always buys the same type of navy blue socks so that he doesn't have to sort them into pairs.
Julian F. G. W.


Does he sort the holy from the wholly unholy?

What about holes in different places: for instance the toe vs under the ball of the foot?

In those circumstances wearing both socks on the same foot provides both adequate coverage and maximum sock utility.

RC

Re: Socks

Posted: August 6th, 2020, 3:03 pm
by GoSeigen
UncleEbenezer wrote:
jfgw wrote:I have a nephew who always buys the same type of navy blue socks so that he doesn't have to sort them into pairs.
Julian F. G. W.


Does he sort the holy from the wholly unholy?

Does he sort the wooly from the un-wooly? [... as the Romans did in Life of Brian...]

GS

Re: Socks

Posted: August 6th, 2020, 4:52 pm
by cinelli
UncleEbenezer wrote:Methinks the level of your 'trap' may not be quite that of regulars here.

I have always tried to vary the level of puzzles so as not to exclude people.

For lovers of Father Ted: did you know that priests don't wear black socks? The colour is very very very very very very very very very very very dark blue.

Cinelli

Re: Socks

Posted: August 6th, 2020, 5:54 pm
by bluedonkey
cinelli wrote:
UncleEbenezer wrote:Methinks the level of your 'trap' may not be quite that of regulars here.

I have always tried to vary the level of puzzles so as not to exclude people.

For lovers of Father Ted: did you know that priests don't wear black socks? The colour is very very very very very very very very very very very dark blue.

Cinelli

Oh go on! Go on!
Go on go on go on etc ....
Happy to do my bit to lower the usual high tone of puzzle corner.

Re: Socks

Posted: August 6th, 2020, 9:42 pm
by jfgw
UncleEbenezer wrote:Does he sort the holy from the wholly unholy?

What about holes in different places: for instance the toe vs under the ball of the foot?

I'm not sure. Maybe, if he gets a hole in one, he cuts corresponding holes in all of the others so that they still all match.


Julian F. G. W.

Re: Socks

Posted: August 8th, 2020, 9:38 pm
by Gengulphus
jfgw wrote:
UncleEbenezer wrote:What about holes in different places: for instance the toe vs under the ball of the foot?

I'm not sure. Maybe, if he gets a hole in one, he cuts corresponding holes in all of the others so that they still all match.

Surely the more traditional way of responding to a hole in one involves a round of drinks in the clubhouse? ;-)

More seriously, a somewhat more challenging problem: for which numbers of socks, some black and some white, is it possible for the probability that two socks drawn at random are both white to be exactly 1/2? And for such collections of socks, how large can the probability that two socks drawn at random are both black be made?

Gengulphus

Re: Socks

Posted: August 8th, 2020, 11:00 pm
by Mike4
Talking about holes in socks, it is interesting to note that all socks have a hole.

The hole you pass your foot through when putting it on.

:)

Re: Socks

Posted: August 8th, 2020, 11:02 pm
by UncleEbenezer
Gengulphus wrote:More seriously, a somewhat more challenging problem: for which numbers of socks, some black and some white, is it possible for the probability that two socks drawn at random are both white to be exactly 1/2? And for such collections of socks, how large can the probability that two socks drawn at random are both black be made?

Gengulphus


The first part of that is a generalised statement of bluedonkey's equation: solutions to s(s-1) = 2w(w-1). Enumerating them is left as an exercise for the reader.

The secnd part of your question is easier. We have a lower bound of sqrt(1/2) on w/s. Since b=s-w, we have an upper bound of (1-sqrt(1/2)) on b/s and hence (1-sqrt(1/2)) squared on (b/s) squared - which is in turn an upper bound on b(b-1)/(s(s-1)). So the probability of two blacks must remain below 1.5 - sqrt(2), which is a little under 8.6%.

Re: Socks

Posted: August 9th, 2020, 1:16 am
by UncleEbenezer
UncleEbenezer wrote:
Gengulphus wrote:More seriously, a somewhat more challenging problem: for which numbers of socks, some black and some white, is it possible for the probability that two socks drawn at random are both white to be exactly 1/2? And for such collections of socks, how large can the probability that two socks drawn at random are both black be made?

Gengulphus


The first part of that is a generalised statement of bluedonkey's equation: solutions to s(s-1) = 2w(w-1). Enumerating them is left as an exercise for the reader.

The secnd part of your question is easier. We have a lower bound of sqrt(1/2) on w/s. Since b=s-w, we have an upper bound of (1-sqrt(1/2)) on b/s and hence (1-sqrt(1/2)) squared on (b/s) squared - which is in turn an upper bound on b(b-1)/(s(s-1)). So the probability of two blacks must remain below 1.5 - sqrt(2), which is a little under 8.6%.


OK, I set the 'puter to enumerate low solutions. Highest it gave was s=803761, w=568345. With those numbers the number of blacks is 235416, and the probability of two blacks is 235416*235415/(803761*803760). Which is just under the theoretical upper bound: indeed, identical to six decimal places (0.085786).

Re: Socks

Posted: August 9th, 2020, 11:25 am
by Gengulphus
UncleEbenezer wrote:
Gengulphus wrote:More seriously, a somewhat more challenging problem: for which numbers of socks, some black and some white, is it possible for the probability that two socks drawn at random are both white to be exactly 1/2? And for such collections of socks, how large can the probability that two socks drawn at random are both black be made?

The first part of that is a generalised statement of bluedonkey's equation: solutions to s(s-1) = 2w(w-1). Enumerating them is left as an exercise for the reader.

Yes, an exercise for the reader that is pretty trivially equivalent to the question I posed - no marks for repeating that exercise-setting! ;-)

UncleEbenezer wrote:The secnd part of your question is easier. We have a lower bound of sqrt(1/2) on w/s. Since b=s-w, we have an upper bound of (1-sqrt(1/2)) on b/s and hence (1-sqrt(1/2)) squared on (b/s) squared - which is in turn an upper bound on b(b-1)/(s(s-1)). So the probability of two blacks must remain below 1.5 - sqrt(2), which is a little under 8.6%.

Yes, and your computerised search shows that it can get very close to 1.5 - sqrt(2). But can it get arbitrarily close?

Gengulphus

Re: Socks

Posted: August 9th, 2020, 2:07 pm
by UncleEbenezer
Gengulphus wrote:
UncleEbenezer wrote:
Gengulphus wrote:More seriously, a somewhat more challenging problem: for which numbers of socks, some black and some white, is it possible for the probability that two socks drawn at random are both white to be exactly 1/2? And for such collections of socks, how large can the probability that two socks drawn at random are both black be made?

The first part of that is a generalised statement of bluedonkey's equation: solutions to s(s-1) = 2w(w-1). Enumerating them is left as an exercise for the reader.

Yes, an exercise for the reader that is pretty trivially equivalent to the question I posed - no marks for repeating that exercise-setting! ;-)

Enumerations don't interest me. Generalities do - hence the focus on the second part of your question. I expect I'm missing some blindingly-obvious insight into the equation there.
UncleEbenezer wrote:The secnd part of your question is easier. We have a lower bound of sqrt(1/2) on w/s. Since b=s-w, we have an upper bound of (1-sqrt(1/2)) on b/s and hence (1-sqrt(1/2)) squared on (b/s) squared - which is in turn an upper bound on b(b-1)/(s(s-1)). So the probability of two blacks must remain below 1.5 - sqrt(2), which is a little under 8.6%.

Yes, and your computerised search shows that it can get very close to 1.5 - sqrt(2). But can it get arbitrarily close?

Gengulphus


'puter gets it to eleven decimal places with s=183648021600, w=129858761425 (and a smarter search than last night).

But since the upper bound is asymptotic, the question is to prove whether or not there's an infinitude of solutions. Though not to socks in drawers: we've surely already exceeded the planet's capacity for socks. You may be Mr Shine, but my poor brain needs the Pork Futures Warehouse.

Re: Socks

Posted: August 10th, 2020, 10:20 am
by UncleEbenezer
Damn, fell asleep composing this last night!

OK, brain's still overheated, but has had the relief of a good long walkies, a dip in a local river, and a goodly dose of mediocre Portuguese plonk. The key I was missing is the sequence itself: each s/w/b triplet tends aymptotically to values (1 / (2(1.5-sqrt(2))) times its predecessor. Here's a hack that finds solutions quickly and efficiently by recursion. If anyone wants to rewrite it in arbitrary-precision arithmetic, you could take this a long way.

Code: Select all

#include <stdio.h>
#include <math.h>

static double sqrt2;
static double seek_ratio;
static double last_ratio;
static double bproblim;

void findnext(long long unsigned int last) {
  long long unsigned int w, s, b;
  double bprob;
  for (w = 1 + last*seek_ratio; w > last; w--) {
    for (s = w*sqrt2; s<w*last_ratio; s++) {
      if (2*w*(w-1) == s*(s-1)) {

        b = s - w;
        bprob = 1.0*b/s*(b-1)/(s-1);
        printf("%lld/%lld   %le\n", s, w, bproblim - bprob);
        last_ratio = 2.0 * w / s;
        findnext(w);
        return;  /* never happens, but structures our would-be exit from the search loop */
      }
    }
  }
}
int main() {
  sqrt2 = sqrt(2.0);
  last_ratio = 2.0;
  bproblim = 1.5 - sqrt(2.0);
  seek_ratio = 1 / (2*bproblim);
  findnext(1);
  return 0;
}


It shows solutions, and the shrinking difference between bprob (probability of two blacks) and the theoretical limit, up to the limit of our integer type:
4/3	8.578644e-02
21/15 1.435787e-02
120/85 2.453104e-03
697/493 4.205840e-04
4060/2871 7.215191e-05
23661/16731 1.237905e-05
137904/97513 2.123901e-06
803761/568345 3.644036e-07
4684660/3312555 6.252177e-08
27304197/19306983 1.072704e-08
159140520/112529341 1.840469e-09
927538921/655869061 3.157745e-10
5406093004/3822685023 5.417825e-11
31509019101/22280241075 9.295439e-12
183648021600/129858761425 1.594752e-12
1070379110497/756872327473 2.735312e-13
6238626641380/4411375203411 4.685141e-14
36361380737781/25711378892991 7.965850e-15
211929657785304/149856898154533 1.290634e-15
1235216565974041/873430010034205 1.387779e-16

Re: Socks

Posted: August 10th, 2020, 6:16 pm
by Gengulphus
UncleEbenezer wrote:
Gengulphus wrote:
UncleEbenezer wrote:The first part of that is a generalised statement of bluedonkey's equation: solutions to s(s-1) = 2w(w-1). Enumerating them is left as an exercise for the reader.

Yes, an exercise for the reader that is pretty trivially equivalent to the question I posed - no marks for repeating that exercise-setting! ;-)

Enumerations don't interest me. Generalities do - hence the focus on the second part of your question. I expect I'm missing some blindingly-obvious insight into the equation there.

OK, a stricter meaning of "enumerating" than I thought you meant... I think I was misled by your use of computer searches, since all a computer search can ever produce is an enumeration of a finite number of solutions. So when there appear to be infinitely many solutions (which your computer search does suggest!) a computer search can do is put you on the trail towards generalities - which I think is where you're trying to go...

Anyway, as a hint, bluedonkey's equation is of a type that is well known to be solvable for any particular value of s (or for any particular value of w, or indeed after substituting s = w+b, for any particular value of b)...

Gengulphus