How to calculate the probability of drawing numbers under certain constraints We have numbers $1,2,3,\dots, n$, where $n$ is an integer, and we select $d$ distinct numbers from them, $i_1,i_2,\dots,i_d$. What is the probability that there exist at least two numbers whose difference is less than $k$, i.e $|i_{h}-i_{j}|<k$, for any $h,j \in \{1,2,3,\dots,d\}$
I am thinking about the total number which satisfies the constraint should be $(n-k+1)(k-1)\binom{n-2}{d-2}$, and the total number is $\binom{n}{d}$,
so the answer should be $\dfrac{(n-k+1)(k-1)\binom{n-2}{d-2}}{\binom{n}{d}}$
Thank you in advance

I think the best approach is to enumerate the number of ways to choose $d$ numbers so that the difference between any two is at least $k$.  That is, we aim to enumerate the number of sets of the form $\{i_1,i_2,\ldots,i_d\}$ such that $|i_j-i_{j-1}|\geq k$ for all $2\leq j\leq d$.
One way to think about this type of problem is via 'stars' and 'bars'.  For example, if $n=7$, $d=3$, and $k=2$ we can consider $**|**|**|*$ to represent the set $\{2,4,6\}$.  Note that each 'bar' represents a number corresponding to the number of stars that come before it.  Notice also that, in order to satisfy the condition that the difference between any two numbers is 2 or greater, we need at least two 'stars' between each bar.
We can come up with the general result using the above observations.  we are choosing $d$ numbers, so we need $d$ bars.  The difference between each consecutive number in our set must be at least $k$, so we need at least $k$ stars between each consecutive pair of bars.  Think of the bars as dividers between bins.  there are $d$ bars, so there are $d+1$ bins.
$$\text{-bin 1-}|\text{-bin 2-}|\cdots|\text{-bin $d+1$-}$$
By our above logic, bins 2 through $d$ must contain at least $k$ stars and bin 1 must contain at least 1 star.  So the number of ways to choose $d$ numbers with pairwise difference at least $k$ amounts to enumerating how many ways we can place the rest of the stars into bins.  We have $k\cdot(d-1)+1$ stars already placed, leaving $n-k(d-1)-1$ stars to be placed in the $d+1$ bins available.
Let $m=n-k(d-1)-1$ and $e=d+1$.  So the question becomes, how many ways are there to place $m$ stars into $e$ bins?  We can answer this question by placing $e-1=d$ dividers anywhere between $m$ stars.  In this scenario the total number of spots for stars or bars is $m+d$ and we are choosing $d$ of them to be bars.  So there are $\binom{m+d}{d}=\binom{n-k(d-1)-1+d}{d}=\binom{n+k+d-kd-1}{d}.$
So the probability you are looking for is
$$1-\frac{\binom{n+k+d-kd-1}{d}}{\binom{n}{d}}=\frac{\binom{n}{d}-\binom{n+k+d-kd-1}{d}}{\binom{n}{d}}.$$
