Expected maximum number of unpaired socksHow to calculate the expected value when betting on which pairings will be selectedNumber of ways I can fit rectangles within a longer rectangleHow many strings contain every letter of the alphabet?a multiset where two consecutive numbers must be dissimilarLetter combinatorics and probabilitiesHow do I create a 4 on 4 tournament where every player plays with every other player an equal number of times?Socks on a clothing lineExpected “overlap” between permutations of a multisetSimilar sequences of coin flipsNumber of unique terms in the nth power of a sum of sinusoids

How to make parshape work inside a tikz node?

Gravitational Force Between Numbers

Why A=2 and B=1 in the call signs for Spirit and Opportunity?

How to teach an undergraduate course without having taken that course formally before?

Dad jokes are fun

Why did Jon Snow do this immoral act if he is so honorable?

What is the difference between LORD and GOD?

Navigating a quick return to previous employer

Why did Jon Snow admit his fault in S08E06?

Why does the hash of infinity have the digits of π?

Why does splatting create a tuple on the rhs but a list on the lhs?

Where is Jon going?

Can a UK national work as a paid shop assistant in the USA?

Do I really need to install Prettier locally?

What would prevent living skin from being a good conductor for magic?

Why was this character made Grand Maester?

Possibility of faking someone's public key

Why isn't 'chemically-strengthened glass' made with potassium carbonate? To begin with?

What is the intuition behind the term Transitive for verbs?

Can you still travel to America on the ESTA waiver program if you have been to Iran in transit?

Why does Bran want to find Drogon?

Interpreation ROC AUC score

Why sampling a periodic signal doesn't yield a periodic discrete signal?

The Most Powerful Number



Expected maximum number of unpaired socks


How to calculate the expected value when betting on which pairings will be selectedNumber of ways I can fit rectangles within a longer rectangleHow many strings contain every letter of the alphabet?a multiset where two consecutive numbers must be dissimilarLetter combinatorics and probabilitiesHow do I create a 4 on 4 tournament where every player plays with every other player an equal number of times?Socks on a clothing lineExpected “overlap” between permutations of a multisetSimilar sequences of coin flipsNumber of unique terms in the nth power of a sum of sinusoids













16












$begingroup$


Like all combinatoric problems, this one is probably equivalent to another, well-known one, but I haven't managed to find such an equivalent problem (and OEIS didn't help), so I offer this one as being possibly new and possibly interesting.



Problem statement



I have $2N$ socks in a laundry basket, and I am hanging them on the hot pipes to dry. To make life easier later, I want to hang them in pairs. Since it is dark where the pipes are, I adopt the following algorithm:



  1. Take a sock at random from the basket.

  2. If it matches one that is already on my arm, hang them both on the pipes: the one in my hand and the matching one taken from my arm.

  3. If it does not match one that is already on my arm, hang it on my arm with the others.

  4. Do this $2N$ times.

The question is: How long does my arm have to be?



Clearly, the minimum length is $1$, for instance if the socks come out in the order $AABBCC$. Equally clearly, the maximum length is $N$, for instance if the socks come out as $ABCABC$. But what is the likeliest length? Or the average length? Or what sort of distribution do the required lengths have?



It turns out to be easiest to parameterise the results not by $2N$, the number of socks, but by $2N-1$, which I will call $M$.



The first few results



(Notation: $n!!$ is the semifactorial, the factorial including only odd numbers; thus $7!!=7times 5times 3times 1$).



In each case I provide the frequency for each possible arm length, starting with a length of 1. I use frequencies rather than probabilities because they are easier to type, but you can get the probabilities by dividing by $M!!$.



$$
beginarrayc
M \
hline
1 & 1 \
3 & 1 & 2 \
5 & 1 & 8 & 6 \
7 & 1 & 30 & 50 & 24 \
9 & 1 & 148 & 340 & 336 & 120 \
endarray
$$

It would be good to know (for example) if these frequencies tend to some sort of known distribution as $Mtoinfty$, just as the binomial coefficients do.



But, as I said at the beginning, this may just be a re-encoding of a known combinatorial problem, carrying a lot of previously worked out results along with it. I thought, for instance, of the lengths of random walks in $N$ dimensions with only one step forward and one step back being allowed in each dimension – but that looked too complicated to give any straightforward direction to follow.



Background: methods



In case it is interesting or helpful, I obtained the results above by means of a two-dimensional generating function, in which the coefficient of $y^n$ identified the arm length needed and the coefficient of $x^n$ identified how many socks had been retrieved at the [first] time that this length was reached. Calling the resulting generating function $A_M(x,y)$, the recurrence I used was:



$$A_M=MxyA_M-2+x^2(x-y)fracpartialpartial xA_M-2+(1-x^2)xy$$



which is based on sound first principles and matches the results of manual calculation up to $M=5$. Having found a polynomial, I substitute $x=1$ and the numbers in the table above are then the coefficients of the powers of $y$.



But, mathematics being close to comedy, all this elaboration may be an unnecessarily complicated way to get to a result too trivial to be found even in OEIS. Is it?










share|cite|improve this question









$endgroup$
















    16












    $begingroup$


    Like all combinatoric problems, this one is probably equivalent to another, well-known one, but I haven't managed to find such an equivalent problem (and OEIS didn't help), so I offer this one as being possibly new and possibly interesting.



    Problem statement



    I have $2N$ socks in a laundry basket, and I am hanging them on the hot pipes to dry. To make life easier later, I want to hang them in pairs. Since it is dark where the pipes are, I adopt the following algorithm:



    1. Take a sock at random from the basket.

    2. If it matches one that is already on my arm, hang them both on the pipes: the one in my hand and the matching one taken from my arm.

    3. If it does not match one that is already on my arm, hang it on my arm with the others.

    4. Do this $2N$ times.

    The question is: How long does my arm have to be?



    Clearly, the minimum length is $1$, for instance if the socks come out in the order $AABBCC$. Equally clearly, the maximum length is $N$, for instance if the socks come out as $ABCABC$. But what is the likeliest length? Or the average length? Or what sort of distribution do the required lengths have?



    It turns out to be easiest to parameterise the results not by $2N$, the number of socks, but by $2N-1$, which I will call $M$.



    The first few results



    (Notation: $n!!$ is the semifactorial, the factorial including only odd numbers; thus $7!!=7times 5times 3times 1$).



    In each case I provide the frequency for each possible arm length, starting with a length of 1. I use frequencies rather than probabilities because they are easier to type, but you can get the probabilities by dividing by $M!!$.



    $$
    beginarrayc
    M \
    hline
    1 & 1 \
    3 & 1 & 2 \
    5 & 1 & 8 & 6 \
    7 & 1 & 30 & 50 & 24 \
    9 & 1 & 148 & 340 & 336 & 120 \
    endarray
    $$

    It would be good to know (for example) if these frequencies tend to some sort of known distribution as $Mtoinfty$, just as the binomial coefficients do.



    But, as I said at the beginning, this may just be a re-encoding of a known combinatorial problem, carrying a lot of previously worked out results along with it. I thought, for instance, of the lengths of random walks in $N$ dimensions with only one step forward and one step back being allowed in each dimension – but that looked too complicated to give any straightforward direction to follow.



    Background: methods



    In case it is interesting or helpful, I obtained the results above by means of a two-dimensional generating function, in which the coefficient of $y^n$ identified the arm length needed and the coefficient of $x^n$ identified how many socks had been retrieved at the [first] time that this length was reached. Calling the resulting generating function $A_M(x,y)$, the recurrence I used was:



    $$A_M=MxyA_M-2+x^2(x-y)fracpartialpartial xA_M-2+(1-x^2)xy$$



    which is based on sound first principles and matches the results of manual calculation up to $M=5$. Having found a polynomial, I substitute $x=1$ and the numbers in the table above are then the coefficients of the powers of $y$.



    But, mathematics being close to comedy, all this elaboration may be an unnecessarily complicated way to get to a result too trivial to be found even in OEIS. Is it?










    share|cite|improve this question









    $endgroup$














      16












      16








      16


      9



      $begingroup$


      Like all combinatoric problems, this one is probably equivalent to another, well-known one, but I haven't managed to find such an equivalent problem (and OEIS didn't help), so I offer this one as being possibly new and possibly interesting.



      Problem statement



      I have $2N$ socks in a laundry basket, and I am hanging them on the hot pipes to dry. To make life easier later, I want to hang them in pairs. Since it is dark where the pipes are, I adopt the following algorithm:



      1. Take a sock at random from the basket.

      2. If it matches one that is already on my arm, hang them both on the pipes: the one in my hand and the matching one taken from my arm.

      3. If it does not match one that is already on my arm, hang it on my arm with the others.

      4. Do this $2N$ times.

      The question is: How long does my arm have to be?



      Clearly, the minimum length is $1$, for instance if the socks come out in the order $AABBCC$. Equally clearly, the maximum length is $N$, for instance if the socks come out as $ABCABC$. But what is the likeliest length? Or the average length? Or what sort of distribution do the required lengths have?



      It turns out to be easiest to parameterise the results not by $2N$, the number of socks, but by $2N-1$, which I will call $M$.



      The first few results



      (Notation: $n!!$ is the semifactorial, the factorial including only odd numbers; thus $7!!=7times 5times 3times 1$).



      In each case I provide the frequency for each possible arm length, starting with a length of 1. I use frequencies rather than probabilities because they are easier to type, but you can get the probabilities by dividing by $M!!$.



      $$
      beginarrayc
      M \
      hline
      1 & 1 \
      3 & 1 & 2 \
      5 & 1 & 8 & 6 \
      7 & 1 & 30 & 50 & 24 \
      9 & 1 & 148 & 340 & 336 & 120 \
      endarray
      $$

      It would be good to know (for example) if these frequencies tend to some sort of known distribution as $Mtoinfty$, just as the binomial coefficients do.



      But, as I said at the beginning, this may just be a re-encoding of a known combinatorial problem, carrying a lot of previously worked out results along with it. I thought, for instance, of the lengths of random walks in $N$ dimensions with only one step forward and one step back being allowed in each dimension – but that looked too complicated to give any straightforward direction to follow.



      Background: methods



      In case it is interesting or helpful, I obtained the results above by means of a two-dimensional generating function, in which the coefficient of $y^n$ identified the arm length needed and the coefficient of $x^n$ identified how many socks had been retrieved at the [first] time that this length was reached. Calling the resulting generating function $A_M(x,y)$, the recurrence I used was:



      $$A_M=MxyA_M-2+x^2(x-y)fracpartialpartial xA_M-2+(1-x^2)xy$$



      which is based on sound first principles and matches the results of manual calculation up to $M=5$. Having found a polynomial, I substitute $x=1$ and the numbers in the table above are then the coefficients of the powers of $y$.



      But, mathematics being close to comedy, all this elaboration may be an unnecessarily complicated way to get to a result too trivial to be found even in OEIS. Is it?










      share|cite|improve this question









      $endgroup$




      Like all combinatoric problems, this one is probably equivalent to another, well-known one, but I haven't managed to find such an equivalent problem (and OEIS didn't help), so I offer this one as being possibly new and possibly interesting.



      Problem statement



      I have $2N$ socks in a laundry basket, and I am hanging them on the hot pipes to dry. To make life easier later, I want to hang them in pairs. Since it is dark where the pipes are, I adopt the following algorithm:



      1. Take a sock at random from the basket.

      2. If it matches one that is already on my arm, hang them both on the pipes: the one in my hand and the matching one taken from my arm.

      3. If it does not match one that is already on my arm, hang it on my arm with the others.

      4. Do this $2N$ times.

      The question is: How long does my arm have to be?



      Clearly, the minimum length is $1$, for instance if the socks come out in the order $AABBCC$. Equally clearly, the maximum length is $N$, for instance if the socks come out as $ABCABC$. But what is the likeliest length? Or the average length? Or what sort of distribution do the required lengths have?



      It turns out to be easiest to parameterise the results not by $2N$, the number of socks, but by $2N-1$, which I will call $M$.



      The first few results



      (Notation: $n!!$ is the semifactorial, the factorial including only odd numbers; thus $7!!=7times 5times 3times 1$).



      In each case I provide the frequency for each possible arm length, starting with a length of 1. I use frequencies rather than probabilities because they are easier to type, but you can get the probabilities by dividing by $M!!$.



      $$
      beginarrayc
      M \
      hline
      1 & 1 \
      3 & 1 & 2 \
      5 & 1 & 8 & 6 \
      7 & 1 & 30 & 50 & 24 \
      9 & 1 & 148 & 340 & 336 & 120 \
      endarray
      $$

      It would be good to know (for example) if these frequencies tend to some sort of known distribution as $Mtoinfty$, just as the binomial coefficients do.



      But, as I said at the beginning, this may just be a re-encoding of a known combinatorial problem, carrying a lot of previously worked out results along with it. I thought, for instance, of the lengths of random walks in $N$ dimensions with only one step forward and one step back being allowed in each dimension – but that looked too complicated to give any straightforward direction to follow.



      Background: methods



      In case it is interesting or helpful, I obtained the results above by means of a two-dimensional generating function, in which the coefficient of $y^n$ identified the arm length needed and the coefficient of $x^n$ identified how many socks had been retrieved at the [first] time that this length was reached. Calling the resulting generating function $A_M(x,y)$, the recurrence I used was:



      $$A_M=MxyA_M-2+x^2(x-y)fracpartialpartial xA_M-2+(1-x^2)xy$$



      which is based on sound first principles and matches the results of manual calculation up to $M=5$. Having found a polynomial, I substitute $x=1$ and the numbers in the table above are then the coefficients of the powers of $y$.



      But, mathematics being close to comedy, all this elaboration may be an unnecessarily complicated way to get to a result too trivial to be found even in OEIS. Is it?







      combinatorics generating-functions






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked 11 hours ago









      Martin KochanskiMartin Kochanski

      2,049310




      2,049310




















          3 Answers
          3






          active

          oldest

          votes


















          10












          $begingroup$

          I did some Monte Carlo with this interesting problem and came to some interesting conclusions. If you have $N$ pairs of socks the expected maximum arm length is slightly above $N/2$.



          First, I made 1,000,000 experiments with 100 pairs of socks and recorded maximum arm length reached in each one. For example, maximum arm length of 54 was reached about 90,000 times. And it all looks like a normal distribution to me. The average value of maximum arm length was 53.91, confirmed several times in a row.



          enter image description here



          Nothing changed with 100 pairs of socks and 10,000,000 experiments. Average value remained the same. So it looks like you need about a million runs to draw up a meaningful conclusion.



          enter image description here



          Here is what I got when I doubled the number of socks to 200 pairs. Maximum arm length on average was 105.12, still above 50%. I got the same value in several repeated experiments ($pm0.01$).



          enter image description here



          Finally, I decided to check expected maximum arm length for different number of sock pairs, from 10 to 250. Each number of pairs was tested 2,000,000 times before the average value was calculated. Here are the results:



          $$
          beginarrayc
          textbfPairs & textbfArm Length & textbfIncrement \
          hline
          10 & 6.49 & \
          20 & 12.03 & 5.54 \
          30 & 17.41 & 5.38 \
          40 & 22.71 & 5.30 \
          50 & 27.97 & 5.26 \
          60 & 33.20 & 5.23 \
          70 & 38.40 & 5.20 \
          80 & 43.59 & 5.19 \
          90 & 48.75 & 5.16 \
          100 & 53.91 & 5.16 \
          110 & 59.07 & 5.16 \
          120 & 64.20 & 5.13 \
          130 & 69.33 & 5.13 \
          140 & 74.46 & 5.13 \
          150 & 79.58 & 5.12 \
          160 & 84.69 & 5.11 \
          170 & 89.80 & 5.11 \
          180 & 94.91 & 5.11 \
          190 & 100.02 & 5.11 \
          200 & 105.11 & 5.09 \
          210 & 110.20 & 5.09 \
          220 & 115.29 & 5.09 \
          230 & 120.38 & 5.09 \
          240 & 125.47 & 5.09 \
          250 & 130.56 & 5.09
          endarray
          $$



          enter image description here



          It looks like a straight line but it's actually an arc, slightly bended downwards (take a look at the increment column).



          Finally, here is the Java code that I used for my experiments.



          import java.util.ArrayList;
          import java.util.Collections;
          import java.util.HashSet;
          import java.util.List;
          import java.util.Set;

          public class Basket
          public static final int PAIRS = 250;
          public static final int NUM_EXPERIMENTS = 2_000_000;

          int n;
          List<Integer> basket;
          Set<Integer> arm;

          public Basket(int n)
          // basket size
          this.n = n;
          // socks are here
          this.basket = new ArrayList<Integer>();
          // arm is just a set of different socks
          this.arm = new HashSet<Integer>();
          // add a pair of same socks to the basket
          for(int i = 0; i < n; i++)
          basket.add(i);
          basket.add(i);

          // shuffle the basket
          Collections.shuffle(basket);


          // returns maximum arm length
          int hangSocks()
          // maximum arm length
          int maxArmLength = 0;
          // we have to hang all socks
          for(int i = 0; i < 2 * n; i++)
          // take one sock from the basket
          int sock = basket.get(i);
          // if the sock of the same color is already on your arm...
          if(arm.contains(sock))
          // ...remove sock from your arm and put the pair over the hot pipe
          arm.remove(sock);

          else
          // put the sock on your arm
          arm.add(sock);
          // update maximum arm length
          maxArmLength = Math.max(maxArmLength, arm.size());


          return maxArmLength;


          public static void main(String[] args)
          // results of our experiments will be stored here
          int[] results = new int[PAIRS + 1];
          // run millions of experiments
          for(int i = 0; i < NUM_EXPERIMENTS; i++)
          Basket b = new Basket(PAIRS);
          // arm length in a single experiment
          int length = b.hangSocks();
          // remember how often this result appeared
          results[length]++;

          // print results in CSV format so that we can plot them in Excel
          for(int i = 0; i < results.length; i++)
          System.out.println(i + "," + results[i]);

          // find average arm length
          int sum = 0;
          for(int i = 0; i < results.length; i++)
          sum += i * results[i];

          double average = (double) sum / (double) NUM_EXPERIMENTS;
          System.out.println(String.format("Average arm length is %.2f", average));





          EDIT: For N=500, the average value of maximum arm length after 2,000,000 tests is 257.19. For N=1000, the result is 509.23.



          It seems that for $Ntoinfty$, the result goes down to $N/2$. I don't know how to prove this.






          share|cite|improve this answer











          $endgroup$












          • $begingroup$
            Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
            $endgroup$
            – Martin Kochanski
            4 hours ago










          • $begingroup$
            @MartinKochanski I'll get back to you tomorrow.
            $endgroup$
            – Oldboy
            2 hours ago










          • $begingroup$
            Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
            $endgroup$
            – Martin Kochanski
            2 hours ago


















          5












          $begingroup$

          The expected number of single socks is maximized when you are halfway through. When you have drawn $N$ socks the chance that a given pair has one on your arm is $frac N^2N^2+N(N-1)=fracN^22N^2-Napprox frac 12+frac 12N$. If we make the socks distinguishable, to have one on your arm sock $1$ of a pair has $2N$ positions it can be in, then sock $2$ has $N$ choices-to be in the other half of the run. To not have one on your arm sock $1$ again has $2N$ choices but sock $2$ has only $N-1$ as it must be in the same half of the run. This says the expected number on your arm is $frac N^22N-1approx frac N+12$.



          The expected value being below the mode of Oldboy's distributions says that the distribution is not symmetric around the mode.






          share|cite|improve this answer









          $endgroup$




















            4












            $begingroup$

            The extra bits, above $N/2$ in Oldboy's table, are near $sqrt[3]N$. I have some ideas why that might be true.



            First, the expected number of socks on the arm at the $N+x$th sock is $(N^2-x^2)/2$.



            Near the $N$th sock, the number of socks on the arm follows a random walk. It is symmetric at the $N$th sock, but has a negative bias of $x^2/2N$ at the $N+x$th sock.

            Around the $N+yN^2/3$th sock, a symmetric random walk would have moved $O(sqrtyN^2/3$, but the negative bias is also $O((yN^2/3)^2/N)$, so both are $O(N^1/3)$. The negative bias will dominate for large $y$, so the maximum value will be in this domain. The random variation dominates for small $y$.



            So the maximum is likely to be $N/2+O(N^1/3)$






            share|cite|improve this answer









            $endgroup$













              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "69"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              noCode: true, onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3234157%2fexpected-maximum-number-of-unpaired-socks%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              10












              $begingroup$

              I did some Monte Carlo with this interesting problem and came to some interesting conclusions. If you have $N$ pairs of socks the expected maximum arm length is slightly above $N/2$.



              First, I made 1,000,000 experiments with 100 pairs of socks and recorded maximum arm length reached in each one. For example, maximum arm length of 54 was reached about 90,000 times. And it all looks like a normal distribution to me. The average value of maximum arm length was 53.91, confirmed several times in a row.



              enter image description here



              Nothing changed with 100 pairs of socks and 10,000,000 experiments. Average value remained the same. So it looks like you need about a million runs to draw up a meaningful conclusion.



              enter image description here



              Here is what I got when I doubled the number of socks to 200 pairs. Maximum arm length on average was 105.12, still above 50%. I got the same value in several repeated experiments ($pm0.01$).



              enter image description here



              Finally, I decided to check expected maximum arm length for different number of sock pairs, from 10 to 250. Each number of pairs was tested 2,000,000 times before the average value was calculated. Here are the results:



              $$
              beginarrayc
              textbfPairs & textbfArm Length & textbfIncrement \
              hline
              10 & 6.49 & \
              20 & 12.03 & 5.54 \
              30 & 17.41 & 5.38 \
              40 & 22.71 & 5.30 \
              50 & 27.97 & 5.26 \
              60 & 33.20 & 5.23 \
              70 & 38.40 & 5.20 \
              80 & 43.59 & 5.19 \
              90 & 48.75 & 5.16 \
              100 & 53.91 & 5.16 \
              110 & 59.07 & 5.16 \
              120 & 64.20 & 5.13 \
              130 & 69.33 & 5.13 \
              140 & 74.46 & 5.13 \
              150 & 79.58 & 5.12 \
              160 & 84.69 & 5.11 \
              170 & 89.80 & 5.11 \
              180 & 94.91 & 5.11 \
              190 & 100.02 & 5.11 \
              200 & 105.11 & 5.09 \
              210 & 110.20 & 5.09 \
              220 & 115.29 & 5.09 \
              230 & 120.38 & 5.09 \
              240 & 125.47 & 5.09 \
              250 & 130.56 & 5.09
              endarray
              $$



              enter image description here



              It looks like a straight line but it's actually an arc, slightly bended downwards (take a look at the increment column).



              Finally, here is the Java code that I used for my experiments.



              import java.util.ArrayList;
              import java.util.Collections;
              import java.util.HashSet;
              import java.util.List;
              import java.util.Set;

              public class Basket
              public static final int PAIRS = 250;
              public static final int NUM_EXPERIMENTS = 2_000_000;

              int n;
              List<Integer> basket;
              Set<Integer> arm;

              public Basket(int n)
              // basket size
              this.n = n;
              // socks are here
              this.basket = new ArrayList<Integer>();
              // arm is just a set of different socks
              this.arm = new HashSet<Integer>();
              // add a pair of same socks to the basket
              for(int i = 0; i < n; i++)
              basket.add(i);
              basket.add(i);

              // shuffle the basket
              Collections.shuffle(basket);


              // returns maximum arm length
              int hangSocks()
              // maximum arm length
              int maxArmLength = 0;
              // we have to hang all socks
              for(int i = 0; i < 2 * n; i++)
              // take one sock from the basket
              int sock = basket.get(i);
              // if the sock of the same color is already on your arm...
              if(arm.contains(sock))
              // ...remove sock from your arm and put the pair over the hot pipe
              arm.remove(sock);

              else
              // put the sock on your arm
              arm.add(sock);
              // update maximum arm length
              maxArmLength = Math.max(maxArmLength, arm.size());


              return maxArmLength;


              public static void main(String[] args)
              // results of our experiments will be stored here
              int[] results = new int[PAIRS + 1];
              // run millions of experiments
              for(int i = 0; i < NUM_EXPERIMENTS; i++)
              Basket b = new Basket(PAIRS);
              // arm length in a single experiment
              int length = b.hangSocks();
              // remember how often this result appeared
              results[length]++;

              // print results in CSV format so that we can plot them in Excel
              for(int i = 0; i < results.length; i++)
              System.out.println(i + "," + results[i]);

              // find average arm length
              int sum = 0;
              for(int i = 0; i < results.length; i++)
              sum += i * results[i];

              double average = (double) sum / (double) NUM_EXPERIMENTS;
              System.out.println(String.format("Average arm length is %.2f", average));





              EDIT: For N=500, the average value of maximum arm length after 2,000,000 tests is 257.19. For N=1000, the result is 509.23.



              It seems that for $Ntoinfty$, the result goes down to $N/2$. I don't know how to prove this.






              share|cite|improve this answer











              $endgroup$












              • $begingroup$
                Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
                $endgroup$
                – Martin Kochanski
                4 hours ago










              • $begingroup$
                @MartinKochanski I'll get back to you tomorrow.
                $endgroup$
                – Oldboy
                2 hours ago










              • $begingroup$
                Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
                $endgroup$
                – Martin Kochanski
                2 hours ago















              10












              $begingroup$

              I did some Monte Carlo with this interesting problem and came to some interesting conclusions. If you have $N$ pairs of socks the expected maximum arm length is slightly above $N/2$.



              First, I made 1,000,000 experiments with 100 pairs of socks and recorded maximum arm length reached in each one. For example, maximum arm length of 54 was reached about 90,000 times. And it all looks like a normal distribution to me. The average value of maximum arm length was 53.91, confirmed several times in a row.



              enter image description here



              Nothing changed with 100 pairs of socks and 10,000,000 experiments. Average value remained the same. So it looks like you need about a million runs to draw up a meaningful conclusion.



              enter image description here



              Here is what I got when I doubled the number of socks to 200 pairs. Maximum arm length on average was 105.12, still above 50%. I got the same value in several repeated experiments ($pm0.01$).



              enter image description here



              Finally, I decided to check expected maximum arm length for different number of sock pairs, from 10 to 250. Each number of pairs was tested 2,000,000 times before the average value was calculated. Here are the results:



              $$
              beginarrayc
              textbfPairs & textbfArm Length & textbfIncrement \
              hline
              10 & 6.49 & \
              20 & 12.03 & 5.54 \
              30 & 17.41 & 5.38 \
              40 & 22.71 & 5.30 \
              50 & 27.97 & 5.26 \
              60 & 33.20 & 5.23 \
              70 & 38.40 & 5.20 \
              80 & 43.59 & 5.19 \
              90 & 48.75 & 5.16 \
              100 & 53.91 & 5.16 \
              110 & 59.07 & 5.16 \
              120 & 64.20 & 5.13 \
              130 & 69.33 & 5.13 \
              140 & 74.46 & 5.13 \
              150 & 79.58 & 5.12 \
              160 & 84.69 & 5.11 \
              170 & 89.80 & 5.11 \
              180 & 94.91 & 5.11 \
              190 & 100.02 & 5.11 \
              200 & 105.11 & 5.09 \
              210 & 110.20 & 5.09 \
              220 & 115.29 & 5.09 \
              230 & 120.38 & 5.09 \
              240 & 125.47 & 5.09 \
              250 & 130.56 & 5.09
              endarray
              $$



              enter image description here



              It looks like a straight line but it's actually an arc, slightly bended downwards (take a look at the increment column).



              Finally, here is the Java code that I used for my experiments.



              import java.util.ArrayList;
              import java.util.Collections;
              import java.util.HashSet;
              import java.util.List;
              import java.util.Set;

              public class Basket
              public static final int PAIRS = 250;
              public static final int NUM_EXPERIMENTS = 2_000_000;

              int n;
              List<Integer> basket;
              Set<Integer> arm;

              public Basket(int n)
              // basket size
              this.n = n;
              // socks are here
              this.basket = new ArrayList<Integer>();
              // arm is just a set of different socks
              this.arm = new HashSet<Integer>();
              // add a pair of same socks to the basket
              for(int i = 0; i < n; i++)
              basket.add(i);
              basket.add(i);

              // shuffle the basket
              Collections.shuffle(basket);


              // returns maximum arm length
              int hangSocks()
              // maximum arm length
              int maxArmLength = 0;
              // we have to hang all socks
              for(int i = 0; i < 2 * n; i++)
              // take one sock from the basket
              int sock = basket.get(i);
              // if the sock of the same color is already on your arm...
              if(arm.contains(sock))
              // ...remove sock from your arm and put the pair over the hot pipe
              arm.remove(sock);

              else
              // put the sock on your arm
              arm.add(sock);
              // update maximum arm length
              maxArmLength = Math.max(maxArmLength, arm.size());


              return maxArmLength;


              public static void main(String[] args)
              // results of our experiments will be stored here
              int[] results = new int[PAIRS + 1];
              // run millions of experiments
              for(int i = 0; i < NUM_EXPERIMENTS; i++)
              Basket b = new Basket(PAIRS);
              // arm length in a single experiment
              int length = b.hangSocks();
              // remember how often this result appeared
              results[length]++;

              // print results in CSV format so that we can plot them in Excel
              for(int i = 0; i < results.length; i++)
              System.out.println(i + "," + results[i]);

              // find average arm length
              int sum = 0;
              for(int i = 0; i < results.length; i++)
              sum += i * results[i];

              double average = (double) sum / (double) NUM_EXPERIMENTS;
              System.out.println(String.format("Average arm length is %.2f", average));





              EDIT: For N=500, the average value of maximum arm length after 2,000,000 tests is 257.19. For N=1000, the result is 509.23.



              It seems that for $Ntoinfty$, the result goes down to $N/2$. I don't know how to prove this.






              share|cite|improve this answer











              $endgroup$












              • $begingroup$
                Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
                $endgroup$
                – Martin Kochanski
                4 hours ago










              • $begingroup$
                @MartinKochanski I'll get back to you tomorrow.
                $endgroup$
                – Oldboy
                2 hours ago










              • $begingroup$
                Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
                $endgroup$
                – Martin Kochanski
                2 hours ago













              10












              10








              10





              $begingroup$

              I did some Monte Carlo with this interesting problem and came to some interesting conclusions. If you have $N$ pairs of socks the expected maximum arm length is slightly above $N/2$.



              First, I made 1,000,000 experiments with 100 pairs of socks and recorded maximum arm length reached in each one. For example, maximum arm length of 54 was reached about 90,000 times. And it all looks like a normal distribution to me. The average value of maximum arm length was 53.91, confirmed several times in a row.



              enter image description here



              Nothing changed with 100 pairs of socks and 10,000,000 experiments. Average value remained the same. So it looks like you need about a million runs to draw up a meaningful conclusion.



              enter image description here



              Here is what I got when I doubled the number of socks to 200 pairs. Maximum arm length on average was 105.12, still above 50%. I got the same value in several repeated experiments ($pm0.01$).



              enter image description here



              Finally, I decided to check expected maximum arm length for different number of sock pairs, from 10 to 250. Each number of pairs was tested 2,000,000 times before the average value was calculated. Here are the results:



              $$
              beginarrayc
              textbfPairs & textbfArm Length & textbfIncrement \
              hline
              10 & 6.49 & \
              20 & 12.03 & 5.54 \
              30 & 17.41 & 5.38 \
              40 & 22.71 & 5.30 \
              50 & 27.97 & 5.26 \
              60 & 33.20 & 5.23 \
              70 & 38.40 & 5.20 \
              80 & 43.59 & 5.19 \
              90 & 48.75 & 5.16 \
              100 & 53.91 & 5.16 \
              110 & 59.07 & 5.16 \
              120 & 64.20 & 5.13 \
              130 & 69.33 & 5.13 \
              140 & 74.46 & 5.13 \
              150 & 79.58 & 5.12 \
              160 & 84.69 & 5.11 \
              170 & 89.80 & 5.11 \
              180 & 94.91 & 5.11 \
              190 & 100.02 & 5.11 \
              200 & 105.11 & 5.09 \
              210 & 110.20 & 5.09 \
              220 & 115.29 & 5.09 \
              230 & 120.38 & 5.09 \
              240 & 125.47 & 5.09 \
              250 & 130.56 & 5.09
              endarray
              $$



              enter image description here



              It looks like a straight line but it's actually an arc, slightly bended downwards (take a look at the increment column).



              Finally, here is the Java code that I used for my experiments.



              import java.util.ArrayList;
              import java.util.Collections;
              import java.util.HashSet;
              import java.util.List;
              import java.util.Set;

              public class Basket
              public static final int PAIRS = 250;
              public static final int NUM_EXPERIMENTS = 2_000_000;

              int n;
              List<Integer> basket;
              Set<Integer> arm;

              public Basket(int n)
              // basket size
              this.n = n;
              // socks are here
              this.basket = new ArrayList<Integer>();
              // arm is just a set of different socks
              this.arm = new HashSet<Integer>();
              // add a pair of same socks to the basket
              for(int i = 0; i < n; i++)
              basket.add(i);
              basket.add(i);

              // shuffle the basket
              Collections.shuffle(basket);


              // returns maximum arm length
              int hangSocks()
              // maximum arm length
              int maxArmLength = 0;
              // we have to hang all socks
              for(int i = 0; i < 2 * n; i++)
              // take one sock from the basket
              int sock = basket.get(i);
              // if the sock of the same color is already on your arm...
              if(arm.contains(sock))
              // ...remove sock from your arm and put the pair over the hot pipe
              arm.remove(sock);

              else
              // put the sock on your arm
              arm.add(sock);
              // update maximum arm length
              maxArmLength = Math.max(maxArmLength, arm.size());


              return maxArmLength;


              public static void main(String[] args)
              // results of our experiments will be stored here
              int[] results = new int[PAIRS + 1];
              // run millions of experiments
              for(int i = 0; i < NUM_EXPERIMENTS; i++)
              Basket b = new Basket(PAIRS);
              // arm length in a single experiment
              int length = b.hangSocks();
              // remember how often this result appeared
              results[length]++;

              // print results in CSV format so that we can plot them in Excel
              for(int i = 0; i < results.length; i++)
              System.out.println(i + "," + results[i]);

              // find average arm length
              int sum = 0;
              for(int i = 0; i < results.length; i++)
              sum += i * results[i];

              double average = (double) sum / (double) NUM_EXPERIMENTS;
              System.out.println(String.format("Average arm length is %.2f", average));





              EDIT: For N=500, the average value of maximum arm length after 2,000,000 tests is 257.19. For N=1000, the result is 509.23.



              It seems that for $Ntoinfty$, the result goes down to $N/2$. I don't know how to prove this.






              share|cite|improve this answer











              $endgroup$



              I did some Monte Carlo with this interesting problem and came to some interesting conclusions. If you have $N$ pairs of socks the expected maximum arm length is slightly above $N/2$.



              First, I made 1,000,000 experiments with 100 pairs of socks and recorded maximum arm length reached in each one. For example, maximum arm length of 54 was reached about 90,000 times. And it all looks like a normal distribution to me. The average value of maximum arm length was 53.91, confirmed several times in a row.



              enter image description here



              Nothing changed with 100 pairs of socks and 10,000,000 experiments. Average value remained the same. So it looks like you need about a million runs to draw up a meaningful conclusion.



              enter image description here



              Here is what I got when I doubled the number of socks to 200 pairs. Maximum arm length on average was 105.12, still above 50%. I got the same value in several repeated experiments ($pm0.01$).



              enter image description here



              Finally, I decided to check expected maximum arm length for different number of sock pairs, from 10 to 250. Each number of pairs was tested 2,000,000 times before the average value was calculated. Here are the results:



              $$
              beginarrayc
              textbfPairs & textbfArm Length & textbfIncrement \
              hline
              10 & 6.49 & \
              20 & 12.03 & 5.54 \
              30 & 17.41 & 5.38 \
              40 & 22.71 & 5.30 \
              50 & 27.97 & 5.26 \
              60 & 33.20 & 5.23 \
              70 & 38.40 & 5.20 \
              80 & 43.59 & 5.19 \
              90 & 48.75 & 5.16 \
              100 & 53.91 & 5.16 \
              110 & 59.07 & 5.16 \
              120 & 64.20 & 5.13 \
              130 & 69.33 & 5.13 \
              140 & 74.46 & 5.13 \
              150 & 79.58 & 5.12 \
              160 & 84.69 & 5.11 \
              170 & 89.80 & 5.11 \
              180 & 94.91 & 5.11 \
              190 & 100.02 & 5.11 \
              200 & 105.11 & 5.09 \
              210 & 110.20 & 5.09 \
              220 & 115.29 & 5.09 \
              230 & 120.38 & 5.09 \
              240 & 125.47 & 5.09 \
              250 & 130.56 & 5.09
              endarray
              $$



              enter image description here



              It looks like a straight line but it's actually an arc, slightly bended downwards (take a look at the increment column).



              Finally, here is the Java code that I used for my experiments.



              import java.util.ArrayList;
              import java.util.Collections;
              import java.util.HashSet;
              import java.util.List;
              import java.util.Set;

              public class Basket
              public static final int PAIRS = 250;
              public static final int NUM_EXPERIMENTS = 2_000_000;

              int n;
              List<Integer> basket;
              Set<Integer> arm;

              public Basket(int n)
              // basket size
              this.n = n;
              // socks are here
              this.basket = new ArrayList<Integer>();
              // arm is just a set of different socks
              this.arm = new HashSet<Integer>();
              // add a pair of same socks to the basket
              for(int i = 0; i < n; i++)
              basket.add(i);
              basket.add(i);

              // shuffle the basket
              Collections.shuffle(basket);


              // returns maximum arm length
              int hangSocks()
              // maximum arm length
              int maxArmLength = 0;
              // we have to hang all socks
              for(int i = 0; i < 2 * n; i++)
              // take one sock from the basket
              int sock = basket.get(i);
              // if the sock of the same color is already on your arm...
              if(arm.contains(sock))
              // ...remove sock from your arm and put the pair over the hot pipe
              arm.remove(sock);

              else
              // put the sock on your arm
              arm.add(sock);
              // update maximum arm length
              maxArmLength = Math.max(maxArmLength, arm.size());


              return maxArmLength;


              public static void main(String[] args)
              // results of our experiments will be stored here
              int[] results = new int[PAIRS + 1];
              // run millions of experiments
              for(int i = 0; i < NUM_EXPERIMENTS; i++)
              Basket b = new Basket(PAIRS);
              // arm length in a single experiment
              int length = b.hangSocks();
              // remember how often this result appeared
              results[length]++;

              // print results in CSV format so that we can plot them in Excel
              for(int i = 0; i < results.length; i++)
              System.out.println(i + "," + results[i]);

              // find average arm length
              int sum = 0;
              for(int i = 0; i < results.length; i++)
              sum += i * results[i];

              double average = (double) sum / (double) NUM_EXPERIMENTS;
              System.out.println(String.format("Average arm length is %.2f", average));





              EDIT: For N=500, the average value of maximum arm length after 2,000,000 tests is 257.19. For N=1000, the result is 509.23.



              It seems that for $Ntoinfty$, the result goes down to $N/2$. I don't know how to prove this.







              share|cite|improve this answer














              share|cite|improve this answer



              share|cite|improve this answer








              edited 8 hours ago

























              answered 8 hours ago









              OldboyOldboy

              10.4k11442




              10.4k11442











              • $begingroup$
                Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
                $endgroup$
                – Martin Kochanski
                4 hours ago










              • $begingroup$
                @MartinKochanski I'll get back to you tomorrow.
                $endgroup$
                – Oldboy
                2 hours ago










              • $begingroup$
                Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
                $endgroup$
                – Martin Kochanski
                2 hours ago
















              • $begingroup$
                Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
                $endgroup$
                – Martin Kochanski
                4 hours ago










              • $begingroup$
                @MartinKochanski I'll get back to you tomorrow.
                $endgroup$
                – Oldboy
                2 hours ago










              • $begingroup$
                Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
                $endgroup$
                – Martin Kochanski
                2 hours ago















              $begingroup$
              Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
              $endgroup$
              – Martin Kochanski
              4 hours ago




              $begingroup$
              Splendid. There is just one snag (or one advantage!): these figures contradict mine quite strongly. I can't verifiably take my recurrence as far up as your numbers, so I wonder: could you let me know what (a) your average maximum arm length and (b) your commonest maximum arm length are for each of 1 to 9 pairs? With any luck we will get a clear enough and noticeable enough deviation for me to identify where I've been going wrong. I am only asking because you have already written the program and plugging in some small numbers shouldn't be any work.
              $endgroup$
              – Martin Kochanski
              4 hours ago












              $begingroup$
              @MartinKochanski I'll get back to you tomorrow.
              $endgroup$
              – Oldboy
              2 hours ago




              $begingroup$
              @MartinKochanski I'll get back to you tomorrow.
              $endgroup$
              – Oldboy
              2 hours ago












              $begingroup$
              Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
              $endgroup$
              – Martin Kochanski
              2 hours ago




              $begingroup$
              Thanks: I have just done some more working out, and I can see where my recurrence went wrong. So don't bother with any more simulations after all.
              $endgroup$
              – Martin Kochanski
              2 hours ago











              5












              $begingroup$

              The expected number of single socks is maximized when you are halfway through. When you have drawn $N$ socks the chance that a given pair has one on your arm is $frac N^2N^2+N(N-1)=fracN^22N^2-Napprox frac 12+frac 12N$. If we make the socks distinguishable, to have one on your arm sock $1$ of a pair has $2N$ positions it can be in, then sock $2$ has $N$ choices-to be in the other half of the run. To not have one on your arm sock $1$ again has $2N$ choices but sock $2$ has only $N-1$ as it must be in the same half of the run. This says the expected number on your arm is $frac N^22N-1approx frac N+12$.



              The expected value being below the mode of Oldboy's distributions says that the distribution is not symmetric around the mode.






              share|cite|improve this answer









              $endgroup$

















                5












                $begingroup$

                The expected number of single socks is maximized when you are halfway through. When you have drawn $N$ socks the chance that a given pair has one on your arm is $frac N^2N^2+N(N-1)=fracN^22N^2-Napprox frac 12+frac 12N$. If we make the socks distinguishable, to have one on your arm sock $1$ of a pair has $2N$ positions it can be in, then sock $2$ has $N$ choices-to be in the other half of the run. To not have one on your arm sock $1$ again has $2N$ choices but sock $2$ has only $N-1$ as it must be in the same half of the run. This says the expected number on your arm is $frac N^22N-1approx frac N+12$.



                The expected value being below the mode of Oldboy's distributions says that the distribution is not symmetric around the mode.






                share|cite|improve this answer









                $endgroup$















                  5












                  5








                  5





                  $begingroup$

                  The expected number of single socks is maximized when you are halfway through. When you have drawn $N$ socks the chance that a given pair has one on your arm is $frac N^2N^2+N(N-1)=fracN^22N^2-Napprox frac 12+frac 12N$. If we make the socks distinguishable, to have one on your arm sock $1$ of a pair has $2N$ positions it can be in, then sock $2$ has $N$ choices-to be in the other half of the run. To not have one on your arm sock $1$ again has $2N$ choices but sock $2$ has only $N-1$ as it must be in the same half of the run. This says the expected number on your arm is $frac N^22N-1approx frac N+12$.



                  The expected value being below the mode of Oldboy's distributions says that the distribution is not symmetric around the mode.






                  share|cite|improve this answer









                  $endgroup$



                  The expected number of single socks is maximized when you are halfway through. When you have drawn $N$ socks the chance that a given pair has one on your arm is $frac N^2N^2+N(N-1)=fracN^22N^2-Napprox frac 12+frac 12N$. If we make the socks distinguishable, to have one on your arm sock $1$ of a pair has $2N$ positions it can be in, then sock $2$ has $N$ choices-to be in the other half of the run. To not have one on your arm sock $1$ again has $2N$ choices but sock $2$ has only $N-1$ as it must be in the same half of the run. This says the expected number on your arm is $frac N^22N-1approx frac N+12$.



                  The expected value being below the mode of Oldboy's distributions says that the distribution is not symmetric around the mode.







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered 8 hours ago









                  Ross MillikanRoss Millikan

                  305k24201376




                  305k24201376





















                      4












                      $begingroup$

                      The extra bits, above $N/2$ in Oldboy's table, are near $sqrt[3]N$. I have some ideas why that might be true.



                      First, the expected number of socks on the arm at the $N+x$th sock is $(N^2-x^2)/2$.



                      Near the $N$th sock, the number of socks on the arm follows a random walk. It is symmetric at the $N$th sock, but has a negative bias of $x^2/2N$ at the $N+x$th sock.

                      Around the $N+yN^2/3$th sock, a symmetric random walk would have moved $O(sqrtyN^2/3$, but the negative bias is also $O((yN^2/3)^2/N)$, so both are $O(N^1/3)$. The negative bias will dominate for large $y$, so the maximum value will be in this domain. The random variation dominates for small $y$.



                      So the maximum is likely to be $N/2+O(N^1/3)$






                      share|cite|improve this answer









                      $endgroup$

















                        4












                        $begingroup$

                        The extra bits, above $N/2$ in Oldboy's table, are near $sqrt[3]N$. I have some ideas why that might be true.



                        First, the expected number of socks on the arm at the $N+x$th sock is $(N^2-x^2)/2$.



                        Near the $N$th sock, the number of socks on the arm follows a random walk. It is symmetric at the $N$th sock, but has a negative bias of $x^2/2N$ at the $N+x$th sock.

                        Around the $N+yN^2/3$th sock, a symmetric random walk would have moved $O(sqrtyN^2/3$, but the negative bias is also $O((yN^2/3)^2/N)$, so both are $O(N^1/3)$. The negative bias will dominate for large $y$, so the maximum value will be in this domain. The random variation dominates for small $y$.



                        So the maximum is likely to be $N/2+O(N^1/3)$






                        share|cite|improve this answer









                        $endgroup$















                          4












                          4








                          4





                          $begingroup$

                          The extra bits, above $N/2$ in Oldboy's table, are near $sqrt[3]N$. I have some ideas why that might be true.



                          First, the expected number of socks on the arm at the $N+x$th sock is $(N^2-x^2)/2$.



                          Near the $N$th sock, the number of socks on the arm follows a random walk. It is symmetric at the $N$th sock, but has a negative bias of $x^2/2N$ at the $N+x$th sock.

                          Around the $N+yN^2/3$th sock, a symmetric random walk would have moved $O(sqrtyN^2/3$, but the negative bias is also $O((yN^2/3)^2/N)$, so both are $O(N^1/3)$. The negative bias will dominate for large $y$, so the maximum value will be in this domain. The random variation dominates for small $y$.



                          So the maximum is likely to be $N/2+O(N^1/3)$






                          share|cite|improve this answer









                          $endgroup$



                          The extra bits, above $N/2$ in Oldboy's table, are near $sqrt[3]N$. I have some ideas why that might be true.



                          First, the expected number of socks on the arm at the $N+x$th sock is $(N^2-x^2)/2$.



                          Near the $N$th sock, the number of socks on the arm follows a random walk. It is symmetric at the $N$th sock, but has a negative bias of $x^2/2N$ at the $N+x$th sock.

                          Around the $N+yN^2/3$th sock, a symmetric random walk would have moved $O(sqrtyN^2/3$, but the negative bias is also $O((yN^2/3)^2/N)$, so both are $O(N^1/3)$. The negative bias will dominate for large $y$, so the maximum value will be in this domain. The random variation dominates for small $y$.



                          So the maximum is likely to be $N/2+O(N^1/3)$







                          share|cite|improve this answer












                          share|cite|improve this answer



                          share|cite|improve this answer










                          answered 5 hours ago









                          Empy2Empy2

                          34.1k12562




                          34.1k12562



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Mathematics Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3234157%2fexpected-maximum-number-of-unpaired-socks%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                              François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480