SECTION 6.2 Continuous Random Variables 363
of a geometric random variable. Just as we were able above to
transformrandinto an exponential random variable, we shall (ap-
proximately) transform the TI random integer variable “randInt”
into a geometric random variable.
First of all, the random integer generator has three inputs and has
the form randInt(nmin,nmax,N). The output consists of a se-
quence ofN randomly and uniformly distributed integers between
nmin andnmax. We shall, for convenience, take nmin = 1 and
setn=nmax. We letY be the geometric random variable (with
parameter p), and letX be a randomly-generated uniformly dis-
tributed integer 1≤X≤n. The goal is to find a functiongsuch
that Y = g(X). This will allow us to use the TI calculator to
generate samples of a geometric random variable (and therefore of
a negative binomial random variable).
Note first that
P(Y ≤k) =p+p(1−p)+p(1−p)^2 +···+p(1−p)k−^1 = 1−(1−p)k, k≥ 0
and that
P(X≤h) =
h
n
, 1 ≤h≤n.
At this point we see a potential problem in transforming from the
uniform variable to the geometric: the geometric random variable
has an infinite number of possible outcomes (with decreasing prob-
abilities) and the uniform random variable is an integer between 1
andn. Therefore, we would hope not to lose too much information
by allowingnto be reasonably large (n≈25 seems pretty good).
At any rate, we proceed in analogy with the analysis on page 353:
assuming thatY =g(X) we have