2

I got this question in an online contest today (which is now over).

Anna writes a sequence of positive integers $(a_1, a_2, · · · , a_n)$, such that $$a_1 + a_2 + · · · + a_n = 2023$$ Suppose the sequence Anna picks is equally likely to be any sequence satisfying the above condition. Find the expected value of $n$. Note: The expected value of $n$ is the average value of $n$ across all possibilities.

My attempt: I found that the given equation has $\binom{2022}{n-1}$ solutions for a fixed $n$. My line of reasoning (which you may skip if you are familiar with stars and bars):

In general, it can be combinatorialy shown that $x_1+x_2+\ldots+x_r=n$ has ${}^{n-1}\textrm C_{r-1}$ positive integer solutions for given $n$ and $r$. It's like we have to partition $n$ consecutive dots into $r$ parts such that each part has at least $1$ dot. $\overbrace{\begin{array}{c|c|c|}\hline \underbrace{\cdots}_{x_1} & \underbrace{\cdots}_{x_2} & \underbrace{\cdots}_{x_3} \\ \hline\end{array}\cdots\begin{array}{|c|c}\hline \underbrace{\cdots}_{x_{r-1}} & \underbrace{\cdots}_{x_r} \\ \hline\end{array}}^n\tag*{}$ We need $r-1$ pipes (i.e., $|$) to make $r$ partitions. Out of $n$ dots, we need to distribute one each to $r$ parts. So we are left with $n-r$ dots which can be distributed freely. The number of ways in which we can permutate $r-1$ pipes and $n-r$ dots is: $\dfrac{(n-r+r-1)!}{(n-r)!\cdot(r-1)!}={}^{n-1}\textrm C_{r-1}\tag*{}$

We can vary $n$ from $1$ to $2023$ so the number of possible sequences of positive integers which sum to $2023$ is given by $$\sum_{n=1}^{2023}\binom{2022}{n-1}=2^{2022}$$

The probability that the chosen sequence is of length $r$ is given by $$P(n=r)=\frac{1}{2^{2022}}\binom{2022}{r-1}$$ Thus, the expected value of $n$ is $\sum_{r=1}^{2023}r\cdot P(n=r)$.

Is my assessment correct?

Also, how to arrive at the $2^{2022}$ i.e., the number of possible sequences of any length combinatorically?

  • 1
    here is a relevant question, but the answer just uses the sum in exactly the same way you did. A comment to that answer essentially matches the combinatorial proof I gave below, so I'll switch mine to community. I'll still leave it up until a proper duplicate is found. – lulu Jul 29 '23 at 13:31

2 Answers2

3

Indeed your idea of using pipes in the attempt is more useful than what you might think. Since there are $2022$ possible positions for you to put the pipe, and each gives a different configurations, hence it's actually $2022$ binary choices. (as what lulu has mentioned) So there are $2^{2022}$ partitions, and the expected value of $n$ is $1+2022(0.5)=1012$. (Adding a pipe adds $1$ to $n$)

MafPrivate
  • 4,033
  • I understood the binary choice part. But how did you arrive at $1+2022×0.5$? Did you solve that sum or there's some insight I am missing? – Nothing special Jul 29 '23 at 13:50
  • Oops my bad, I have got it now. There are $2022$ possible positions for placing the pipes and there's one half probability that we put a pipe for each position. There's no need of solving that sum... The $+1$ in the expected value also makes sense because placing $r$ pipes results in a sequence of $r+1$ length... – Nothing special Jul 29 '23 at 14:04
1

This must be a duplicate, but I can't find an answer that exactly matches so I'll post one here until a duplicate is found.

For any $n\in \mathbb N$, start with a string of $n$ $1's$. Now you can place bars (or not) in any of $n-1$ positions to get an ordered partition of the form you want. Hence, $n-1$ binary choices, so there are $2^{n-1}$ such ordered partitions.

lulu
  • 70,402
  • +1... I didn't think this through... I was so much obsessed with solving binomial distributions... – Nothing special Jul 29 '23 at 14:11
  • 2
    Nothing at all wrong with your method. Nor with your instincts...given the way the answers play out, it's clear that there must be a simple combinatorial path to get there. But that doesn't invalidate the direct method. – lulu Jul 29 '23 at 14:24