I want to be able to uniformly draw (finite approximations of) functions $f: [0,1] \to \mathbb{R}$ such that $f(0)=a$, $f(1)=b$, and $|f'(x)|<s$ (for a fixed $s$). I want to do this so I can draw random (natural looking, so derivative at most $s$) curves between two points. My measure theoretic probability is a bit weak, so I didn't quite know what "uniformly" means in this case, and I only need to be able to plot the functions, so I only need a finite set of points of its graph.
So I think my question is asking for an algorithm to uniformly draw from the space of all finite sequences of integers of length $n$ such that $x_1 = a$, $x_n = b$, and for all $k \in \{2,3, \ldots n\}$, $|x_k-x_{k-1}| < s$ for some fixed $s$. This space is finite so I think its clear here what I mean by uniformly.
I had hopes of being able to ignore the boundary conditions and simply scale the solution to match, but the derivative condition kind of messes that up I think. The only clear simplification I can see is translating the problem so $f(0)=0$.
I think I figured out a recursive way to solve this. As should be expected, this is related to the idea behind the binomial formula and Pascal's triangle. I'm not sure whether this has a name or not, but it feels pretty important, so it might. When I say "changing by at most $s$ each time", I mean $|x_r - x_{r-1}| \leq s$.
Let $k_{n,s,y}$ denote the number of sequences of length $n$ who change by at most $s$ and end at $y$. It should be easy enough to see that by truncating any such sequence by 1 gives us a sequence of length $n-1$, changing by at most $s$ each time, and ending at some $y'$ such that $|y-y'|<s$. It should also be clear that every such sequence is obtained by appending $y$ to a sequence of length $n-1$ changing by at most $s$ each time, and ending at some $y'$ such that $|y-y'| \leq s$.
Therefore we have $$ k_{n,s,y} = \sum_{|i-y| \leq s} k_{n-1,s,i},$$ where if $i > s(n-1)$, then $k_{n,s,i} = 0$. The binomial situation is the case $s=1$ except a sequence is not allowed to not move. Here is an example of the values of $k_{n,1,y}$.
It should be fairly easy to see that $\sum_{i} k_{n,s,i} = (2s+1)^n$ by induction. Maybe someone smarter than me can generalise an explicit, non recursive formula for $k_{n,s,y}$. I can't be bothered though, because the recursive method below requires all of the recursive computation of $k_{n,s,y}$.
So to uniformly draw a sequence with parameters $n$, $s$, and $y$, one should recursively calculate $k_{n,s,y}$, then set $x_n=y$. Then select $x_{n-1} = i$ with probability $\begin{cases} k_{n-1,s,i}/k_{n,s,y} & |i-x_n| \leq s \\ 0 &\text{otherwise} \end{cases} $. Continue in this fashion, replacing the denominator with the "current" value of $k$.
For example, if we want a sequence of length 4, ending at 1, with $s=1$, we would set $x_4=1$, then pick $x_3 = 2$ with probability $1/6$, $x_3 = 1$ with probability $2/6$, and $x_3 = 0$ with probability $3/6$. Note here that $6=1+2+3$. We'd then pick $n=2$ based on our result from $n=3$.