Let $I_j={\{1,2,\ldots,j}\}$ for $j \in \mathbb{N}$. For $m,n \in \mathbb{N}$, how many non-decreasing functions $f:I_m \to I_n$ exist?
-
1This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level. – Nick Peterson Jan 09 '14 at 15:01
-
1@Nicholas R. Peterson: The way I see the question is well-defined. About my thoughts, for each number in $I_m$ I can associate it to an a number in $I_n$, so the set of functions from $I_m$ to $I_n$ must have $n^m$ elements. But then I should remove the numbers of functions that are not non-decreasing, I don't know how to proceede. – Raul C. de Assis Jan 09 '14 at 15:13
-
See this post: number of nondecreasing functions – bubbles89 Apr 26 '21 at 15:44
-
See this post: Number of nondecreasing functions – bubbles89 Apr 26 '21 at 15:45
2 Answers
There are $\displaystyle \binom{m+n-1}{m}$ such functions.
One of many ways to see this: I start with two counters, $a$ and $b$, both equal to $1$. I take $m+n-1$ steps. At every step, I either increase $b$, or I output $f(a) = b$ and then increase $a$. Exactly $m$ steps have to be output steps (since I need to define $f$ on all of $I_m$); the other $n-1$ are steps where I increase $b$ (so that $b$ starts with value $1$ and ends at value $n$). Note that some of the increasing steps may take place before any output steps or after all output steps; that's fine (and corresponds to the cases where $f(1)>1$ and $f(m)<n$ respectively). Every non-decreasing $f:I_m\rightarrow I_n$ corresponds to a unique such process, and every such process yields a unique such function.
So it suffices to count the number of such processes, of which there are $\displaystyle\binom{m+n-1}{m}$, since such a process is exactly given by the choice of which $m$ of its steps are output steps.
You might also try to reduce this problem to a balls-in-boxes / stars-and-bars counting problem -- think about nested boxes of balls.
- 8,347
Hint:
Let $N_{m,n}$ denote the number of such functions $f:I_m\to I_n$. You could partition these based on the value of $f(m)$: $$ N_{m,n}=\sum_{k=1}^{n}\lvert\{f:I_m\to I_n\mid f(m)=k\}\rvert. $$ Now, you need to count these.
If you know the value of $f(m)$, what does the restriction of $f$ to $\{1,2,\ldots,m-1\}$ look like? You can use this to find a recurrence relation for $N_{m,n}$.
Alternatively:
If you pick any $i_1,i_2,\ldots,i_n$ such that $i_1+i_2+\cdots+i_n=m$, how many different non-decreasing functions $f:I_m\to I_n$ can you find such that $f(j)=1$ for $i_1$ different $j$, $f(j)=2$ for $i_2$ different $j$, and so on?
- 33,058