Distribution for number of trials before a fixed sum is reached I'm trying to figure out the distribution over a number of trials until a stopping condition is met. In particular, imagine we are observing samples of a uniformly distributed random variable, $X \in \{a,a+1,...,b\}$. We continue to observe samples until the sum of these numbers passes some threshold $Z$ then we stop the process. That is, we have the set $\{x_1, ..., x_T | \sum_{i=1}^T x_i \geq Z\}$.  I'm interested in the distribution over the random variable $T$ (the number of trials). 
This is a similar to a multinomial distribution, or a negative multinomial, but not the same. 
Assuming that $b << Z$, we can ignore the small rounding error right at the end assume that $\sum_{i=1}^T x_i = Z$.  We can then make some basic observations, like $\frac{Z}{a} \leq T \leq \frac{Z}{b}$. Also, from experiments it seems that $\mathbb{E}[T] = \frac{Z}{\mathbb{E}[X]}$, not sure about the variance though, or the general shape of the distribution. 
edit: This question can be answered in part by observing the following, first denote $Y = \sum_{i=1}^N X_i$, we of course, have $Y/N \overset{d}{\to} \mathbb{E}[X]$. Naturally, for any large $N$ we expect $Y \approx N\mathbb{E}[X]$.  In fact, this could also seen from Hoeffding's inequality.  So, for a large enough $Z$, if we constrain $Y=Z$, we have $Z \approx T\mathbb{E}[X]$ or $T \approx \frac{Z}{\mathbb{E}[X]}$ as I observed.
 A: Let $X_1,X_2,\dots$ be iid $\mathrm{Uniform}\{a,a+1,\dots,b\}$. Find the distibution of $S_n=\mathrm{constant} + X_1+\dots+X_n$ using the information starting on page 285 of this document. Use the Hitting Time Theorem to find the distribution of $T=\inf\,\{n\geq 1:S_n=0\}$.
A: My first step would be to just try this out. While writing such a program I typically get a better idea of how to proceed. Here is how I would write it in Stata (and Mata):
clear all
set obs 10000

mata
// for 10,000 obs role a 6-sided die 24 times
x = ceil(6*runiform(10000,24))

// compute a running sum for each observation
for(i=1; i <= 10000; i++) {
    x[i,.] = runningsum(x[i,.])
}

// number of roles till running sum passes 24
T = rowsum(x :< 24)

// add that variable to the dataset
idx =st_addvar("byte","T")
st_store(.,idx,T)
end

// look at T:
spikeplot T


tab T
          T |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |          6        0.06        0.06
          4 |        638        6.38        6.44
          5 |      2,248       22.48       28.92
          6 |      2,976       29.76       58.68
          7 |      2,313       23.13       81.81
          8 |      1,204       12.04       93.85
          9 |        451        4.51       98.36
         10 |        123        1.23       99.59
         11 |         33        0.33       99.92
         12 |          7        0.07       99.99
         13 |          1        0.01      100.00
------------+-----------------------------------
      Total |     10,000      100.00


sum T

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
           T |     10000      6.3238    1.344966          3         13

So T is an integer, it has minimum value $\lfloor Z/b\rfloor-1$ and a maximum of $\lfloor Z/a \rfloor - 1$. I would than take some manageble values of $a$, $b$ and $Z$ and write down the probability of each of the possible values of T and look for a pattern. 
A: Another interesting way to arrive at the same answer is to introduce a second random variable $Y$ which is defined through the following constraint 
$$
Y = Z - \sum_{i=1}^T X_i
.
$$
Intuitively, for any fixed number of trials, $Y$ will make up the remainder of the sum need to reach $Z$.  We can clearly see that 
$$
\mathbb{E}[Y] = Z - T\mathbb{E}[X]
$$
Setting the LHS equal to zero (no remainder), and solving for $T$, we have
$$
T = \frac{Z}{\mathbb{E}[X]}
$$
This only given the expected number of trials until there is no remainder, which is close, but maybe not exactly the same thing...
