The problem was to find the number of ordered pairs x=(x1,x2,…,xn) such that xi≤xi+1 and 1≤xi≤m for all i, xi being a natural number.
Solution
We will present two solutions.
Solution 1)
The first solution uses what is called the Stars and Bars approach.
For each k∈{1,2,…,m} you look at exactly how many xi=k. Call this number yk (note, it could be 0).
We must have that y1+y2+⋯+ym=n, with 0≤yi≤n.
Now given a y=(y1,y2,…,ym) we can easily map this back to the x=(x1,x2,…,xn) from which it was created.
Thus it is enough to count the number of solutions to y1+y2+⋯+ym=n, with 0≤yi≤n.
The way to look at this is to consider n stars, and m−1 vertical bars. Finding a solution to the above equation is equivalent to placing the m−1 bars among the n stars. The number of stars to the left of the leftmost bar is y1, the one next to it is y2 and so on.
The number of ways to do this is to select the position of the stars among a total n+m−1 spots: \binom{n+m-1}{n}
Solution 2)
The second solution I find particularly elegant.
Suppose instead of x_i \le x_{i+1}, we had the condition x_i \le x_{i+1} (i.e. strictly increasing).
Then it is easy to count: just select n among m = \binom{m}{n} (and sort to get the increasing order).
We can reduce our problem to the strictly increasing case.
Set z_i = x_i + i - 1.
Now we have that z_i \lt z_{i+1} (strictly increasing) and that 1 \le z_i \le m + n - 1.
Thus the answer is \binom{m+n-1}{n}
Solution
We will present two solutions.
Solution 1)
The first solution uses what is called the Stars and Bars approach.
For each k∈{1,2,…,m} you look at exactly how many xi=k. Call this number yk (note, it could be 0).
We must have that y1+y2+⋯+ym=n, with 0≤yi≤n.
Now given a y=(y1,y2,…,ym) we can easily map this back to the x=(x1,x2,…,xn) from which it was created.
Thus it is enough to count the number of solutions to y1+y2+⋯+ym=n, with 0≤yi≤n.
The way to look at this is to consider n stars, and m−1 vertical bars. Finding a solution to the above equation is equivalent to placing the m−1 bars among the n stars. The number of stars to the left of the leftmost bar is y1, the one next to it is y2 and so on.
The number of ways to do this is to select the position of the stars among a total n+m−1 spots: \binom{n+m-1}{n}
Solution 2)
The second solution I find particularly elegant.
Suppose instead of x_i \le x_{i+1}, we had the condition x_i \le x_{i+1} (i.e. strictly increasing).
Then it is easy to count: just select n among m = \binom{m}{n} (and sort to get the increasing order).
We can reduce our problem to the strictly increasing case.
Set z_i = x_i + i - 1.
Now we have that z_i \lt z_{i+1} (strictly increasing) and that 1 \le z_i \le m + n - 1.
Thus the answer is \binom{m+n-1}{n}
No comments:
Post a Comment