1

More formally, find the number of ways of dividing a sum $S$ among $N$ numbers — $a_1, a_2, a_3, \dots, a_N$,
such that they are in strictly increasing order i.e. — $a_1 < a_2 < a_3 < \dots < a_n$,
given that $\sum_{i=1}^Na_i = S$ , $a_i >= 0$
Note that the order of the number is fixed.

Consider an example, $N = 3, S = 6$:
Total ways = 3
0, 1, 5
0, 2, 4
1, 2, 3

when $N = 3, S = 7$: Total ways = 4
0, 1, 6
0, 2, 5
0, 3, 4
1, 2, 4

Edit:
The question's previous title asked for the probability, but to find probability I think we ultimately need to find such number of ways (I don't know if there is some other way). Feel free to answer in terms of probability or the number of such ways.

  • What does this have to do with probability? – saulspatz Jul 25 '18 at 14:38
  • @saulspatz Once I know the number of such ways, I can get the probability easily by dividing that into the total number of ways. You can take the question whichever way feels you easy:) – Rahul Goswami Jul 25 '18 at 14:39
  • 2
    If you are given $N$ distinct numbers the chance that they are in increasing order is $1/N!$. The fact that they sum to $S$ doesn't matter at all. – Ross Millikan Jul 25 '18 at 14:41
  • @RossMillikan I never mentioned the numbers to be distinct! They can be equal. I will edit my answer to explicitly mention it. – Rahul Goswami Jul 25 '18 at 14:47
  • 1
    If the numbers can be equal, how can they be strictly increasing as in $a_1 < a_2 < a_3 < \dots < a_N$. – Daniel Buck Jul 25 '18 at 14:52
  • 1
    I still don't understand what you are looking for. The numbers must be distinct if they can be strictly increasing. Are you looking for the number of compositions of $S$ into $N$ parts? The chance that among those compositions you have selected one in increasing order? Or what? – Ross Millikan Jul 25 '18 at 14:57
  • @RossMillikan I added that "need not be distinct" part to mention the total possibilities (for those who want to answer in the form of probability that was originally asked in the title. Yes, the numbers have to be distinct in order to be distinct. – Rahul Goswami Jul 25 '18 at 15:02
  • I think you should just ask for the number of ways. So far you haven’t said anything about a probability distribution for the $a_k$, without which asking for the probability is too vague. Is $N$ fixed? – Brian Tung Jul 25 '18 at 15:23
  • Yes, N is fixed. – Rahul Goswami Jul 25 '18 at 15:24
  • It might help if you edited the question to include an example or two with some small numbers, such as $N=2$ and $S=4$, for which I get $2$ out of $5$ sums to be in strictly increasing order, i.e., $0+4$ and $1+3$ are strictly increasing while $2+2$, $3+1$, and $4+0$ are not. – Barry Cipra Jul 25 '18 at 15:25
  • @BarryCipra Ok, I will add. – Rahul Goswami Jul 25 '18 at 15:27
  • 1
    Good edit. Note that the number of ways to write $S$ as sum of $N$ non-negative integers is $S+N-1\choose N-1$. In my example that's ${4+2-1\choose2-1}={5\choose1}=5$. So the denominator for the probability you're asking for has a nice, simple expressions. It's the numerator that you're really asking about. – Barry Cipra Jul 25 '18 at 15:37
  • Yes @BarryCipra, that is correct. I hope there is some simple expression for the numerator part too. Or at least some easy/intuitive way to calculate it. – Rahul Goswami Jul 25 '18 at 16:04
  • Something similar here https://math.stackexchange.com/questions/2623657/number-of-positive-integral-solutions-of-abcde-20-such-that-abcde-an/2623713#2623713 – rtybase Jul 25 '18 at 17:23

2 Answers2

1

You can solve this with a generating function. Let $$P = \prod_{i=0}^S (1+x^iy)$$

The variable $y$ tracks the number of summands, and $x$ tracks the amount contributed to the sum. Then the number of sequences of $N$ strictly increasing summands adding up to $S$ is the coefficient of $x^Sy^N$ in $P$, since any set of $N$ distinct numbers adding up to $S$ creates a single such sequence due to the dual requirements for the summands being distinct and strictly increasing.

So for example with $N=3$, $S=6$ as above, we get the solution $0,1,5$ from $$(x^0y)(x^1y)(1)(1)(1)(x^5y)$$

You can calculate this for specific values using the MAGMA Online Calculator with the code:

Z<x,y>:=PolynomialRing(Integers(),2);
N:=3;
S:=30;
prod:=&*[1+x^i*y:i in {0..S}];
Coefficient(Coefficient(prod,y,N),x,S);
Jeremy Dover
  • 1,592
1

We will first assume $0$ is not allowed as one of the numbers. We will cover $0$ at the end.

You can write a recurrence. If $A(S,N)$ is the number of ways of writing $S$ as a strictly increasing sum of $N$ numbers greater than $0$, we can look at whether $1$ is one of the numbers. If it is, we need to express $S-1$ as a strictly increasing sum of $N-1$ numbers greater than $1$. Subtract $1$ from them all and $N$ from $S$ and we see there are $A(S-N,N-1)$ ways to write $S$ in a way including $1$.

If $1$ is not included, we need to write $S$ as a sum of $N$ numbers greater than $1$. Again we can subtract $1$ from all the numbers and find there are $A(S-N,N)$ ways to write $S$ as a sum of $N$ numbers not including $1$, so $$A(S,N)=A(S-N,N-1)+A(S-N,N)$$ Given the observation that $A(S,N)=0$ when $S \lt \frac 12N(N+1)$ and $A(S,1)=1$ this will bottom out quickly for reasonable values of $S,N$

Let $B(S,N)$ be the number of ways of expressing $S$ as the increasing sum of $N$ numbers where $0$ is permitted. If $0$ is included there are $A(S,N-1)$ ways. If $0$ is not included, there are $A(S,N)$ ways, so $$B(S,N)=A(S,N-1)+A(S,N)$$ is the final count.

Taking the example of $S=7,N=3$ we have $$B(7,3)=A(7,3)+A(7,2)\\A(7,3)=A(4,2)+A(4,3)=1+0=1\\ A(7,2)=A(5,1)+A(5,2)=1+A(3,1)+A(3,2)=3\\B(7,3)=4$$

Ross Millikan
  • 374,822
  • Great answer and approach! I don't think this recursive equation is solvable (in terms of a single formula), or is it? – Rahul Goswami Jul 25 '18 at 16:40
  • I mean, It is similar to the combinations recursive formula $^nC_r = ^{n-1}C_r + ^{n-1}C_{r-1}$, it has a nice formula. If there is a way we could do the same here? – Rahul Goswami Jul 25 '18 at 16:45
  • 1
    I don't see an obvious one. Partition problems are often hard to express compactly. I would start by generating a big table of the $B$s. Mathematica, which I don't have, would make that easy. It would work in a spreadsheet using the LOOKUP function – Ross Millikan Jul 25 '18 at 16:45
  • 1
    See this link: http://oeis.org/A008289 . – Steve Kass Jul 25 '18 at 16:49
  • @SteveKass: Thank you. That is my $A(S,N)$ No simple formula is given. – Ross Millikan Jul 25 '18 at 17:08
  • @RossMillikan Sorry for disturbing you again if I am asking too much, but I want to ask what would be the recurrence if we had the condition $a_1 \leq a_2 \leq a_3 \dots \leq a_n$? I found this answer https://math.stackexchange.com/q/217597/571724 and the corresponding series https://oeis.org/A000041 . But couldn't understand how he got that recurrence. It is not mentioned in the Wikipedia article or elsewhere. I am not commenting this on that answer because that thread is inactive for 2 years, highly unlikely for any response. – Rahul Goswami Jul 25 '18 at 17:52
  • 1
    He is following the same logic as I am. His recurrence should be $p(k,n)=p(k-1,n-1)+p(k,n-k)$ as Wikipedia says. The first is partitions including at least one $1$, so you remove it and partition $n-1$ into $k-1$ parts. The second is partitions with no $1$, so subtract $1$ from each partition and partition $n-k$ into $k$ parts. – Ross Millikan Jul 25 '18 at 18:05
  • Wow, I really need to brush up my recursive thinking skills. You are awesome @RossMillikan , thanks for the reply. But what if partitions include 0 but not 1? Then we can't subtract 1 from each partition I guess. Moreover, for $k = 2, n = 2$, this solves as 1, but the actual answer being 2 ($(0, 2), (1, 1)$). But if I put $n = n + k$, as from the Note in his recurrence I get 2 correctly. – Rahul Goswami Jul 25 '18 at 18:55
  • 1
    He allows multiple zeros, unlike you. His solution is to add $1$ to each part and prohibit zeros. That is why $n$ goes to $n+k$. He does that first, so they are taken care of and if there is no $1$ we can subtract $1$ from every partition. – Ross Millikan Jul 25 '18 at 20:44