2

I saw this question https://stats.stackexchange.com/a/518651/403725 where the distribution of "gambler ruin times" is derived (Discrete Phase Type Distribution):

$$\mathbb{P}(T=t) = w_0 \cdot \frac{(t - 1)!}{(\tfrac{t+w_0}{2})! (\tfrac{t-w_0}{2})!} \cdot \frac{1}{2^t}.$$

I am interested in learning how random ruin times from this distribution can be simulated in R. As an example, suppose $w_0=6$

I first thought we can use the Probability Integral Transform method:

$$Y = F_X(X)$$ $$X = F_X^{-1}(Y)$$

where:

  • $X$ is a continuous random variable,
  • $F_X$ is the cumulative distribution function of $X$, and
  • $Y$ is a random variable that follows a standard uniform distribution.

As an example of this for the Exponential Distribution (pdf, cdf, inverse cdf) - $X$ is a random number from the exponential distribution and $U$ is Uniform(0,1):

$$f(x;\lambda) = \lambda e^{-\lambda x} \quad \text{for } x \geq 0$$

$$F(x;\lambda) = 1 - e^{-\lambda x} \quad \text{for } x \geq 0$$

$$F^{-1}(y;\lambda) = -\frac{\log(1-y)}{\lambda} \quad \text{for } 0 \leq y < 1$$

$$X = F^{-1}(U;\lambda) = -\frac{\log(1-U)}{\lambda}$$

But in the case of Gamblers Ruin, I am not sure how to work with the CDF of this distribution as it involves summation terms with large factorials:

$$F_T(t) = P(T \leq t) = \sum_{k=0}^{t} P(T=k)$$ $$F_T(t) = \sum_{k=0}^{t} w_0 \cdot \frac{(k - 1)!}{(\tfrac{k+w_0}{2})! (\tfrac{k-w_0}{2})!} \cdot \frac{1}{2^k}$$

I thought maybe we could use some sampling algorithm like Acceptance-Rejection?

  1. Generate a sample $x$ from a proposal distribution that has a density proportional to a function $g(x)$, where $g(x) \geq f(x)$ for all $x$. Here, $f(x)$ is the density of the target distribution.
  2. Generate a uniform random number $u$ between 0 and 1.
  3. If $u > \frac{f(x)}{g(x)}$, reject the sample $x$ and return to step 1; otherwise, accept $x$ as a sample from the target distribution.

So in the case of Gamblers Ruin time, I thought I can do this (e.g. suppose times are between 0 and 100, I can use $g(t)=1/100$:

  1. Generate a proposal sample $t$ from the uniform distribution on the interval $[1, 100]$.
  2. Calculate acceptance probability $a = \frac{\mathbb{P}(T=t)}{g(t)}$.
  3. Generate a uniform random number $u$ between 0 and 1.
  4. If $u \leq a$, accept $t$ as a sample from the target distribution; otherwise, reject $t$ and return to step 1.

Is this approach correct? If so, I am currently working on R code for this and can post my results.

  • A blind application of the alias method will work well here unless the expected time is very high (billions or more). For an example of R code applied to a problem just like this one, see https://stats.stackexchange.com/a/608790/919. But doesn't the thread you reference already answer your question? I see R code there. – whuber Jan 12 '24 at 14:31
  • this is about conway-maxwell-poisson ... is it related to gamblers ruin? – Uk rain troll Jan 12 '24 at 14:38
  • first time i have heard of this term "alias method" (https://en.wikipedia.org/wiki/Alias_method) – Uk rain troll Jan 12 '24 at 14:38
  • would you say the application of the method I used is correct? – Uk rain troll Jan 12 '24 at 16:22
  • 2
    That post is about how to sample from a discrete distribution with potentially large support whose probabilities are given by a formula. That's exactly what your question is--the algebraic details differ but don't really matter. I can't comment on your method because it's generic: the key lies in the details. What would your proposal distribution be and why would you expect your solution to be easier to implement or more efficient than simpler solutions like those I point to? – whuber Jan 12 '24 at 17:30

0 Answers0