# Fast and Stable Algorithms for Computing and Sampling from the Noncentral Hypergeometric Distribution

By Liao, J. G.; Rosen, Ori | The American Statistician, November 2001 | Go to article overview

# Fast and Stable Algorithms for Computing and Sampling from the Noncentral Hypergeometric Distribution

Liao, J. G., Rosen, Ori, The American Statistician

**********

Although the noncentral hypergeometric distribution underlies conditional inference for 2 x 2 tables, major statistical packages lack support for this distribution. This article introduces fast and stable algorithms for computing the noncentral hypergeometric distribution and for sampling from it. The algorithms avoid the expensive and explosive combinatorial numbers by using a recursive relation. The algorithms also take advantage of the sharp concentration of the distribution around its mode to save computing time. A modified inverse method substantially reduces the number of searches in generating a random deviate. The algorithms are implemented in a Java class, Hypergeometric, available on the World Wide Web.

KEY WORDS: Inverse method; Recursive methods; 2 x 2 table.

1. INTRODUCTION

The noncentral hypergeometric distribution underlies conditional inference of 2 x 2 tables. Consider, for example, a clinical trial that compares two treatments. Let the number of subjects allocated to the two treatment groups be [n.sub.1] and [n.sub.2], respectively, and the number of subjects with a positive outcome be [Y.sub.1] and [Y.sub.2]. A natural model is then [Y.sub.i] ~ Binomial([n.sub.i], [[pi].sub.i]), i = 1, 2. For this design, the odds ratio

[psi] = [[pi].sub.1](1 - [[pi].sub.2])/[[pi].sub.2](1 - [[pi].sub.1]),

is often used to measure the relationship between treatment out come and treatment group. Let [m.sub.1] be the sum of the observed value of [Y.sub.1] and [Y.sub.2]. The conditional inference is based on the conditional distribution of [Y.sub.1] given [Y.sub.1] + [Y.sub.2] = [m.sub.1]

[p.sub.i] [equivalent to] Pr([Y.sub.1] = i\[Y.sub.1] + [Y.sub.2] = [m.sub.1])

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]

where l = max(0, [m.sub.1] - [n.sub.2]) and u = min([n.sub.1], [m.sub.1]). For the special case of [psi] = 1, that is, [[pi].sub.1] = [[pi].sub.2], the noncentral distribution reduces to the familiar (central) hypergeometric distribution, on which Fisher's exact test is based. The same formulation applies to conditional inference of 2 x 2 tables where each cell follows a Poisson distribution. See, for example, Fisher (1935), Breslow and Day (1980), Agresti (1992), and McCullagh and Nelder (1989, chap. 7). The noncentral hypergeometric distribution thus has wide applications in medical, epidemiological, and social studies.

This article studies efficient algorithms for computing and sampling from the noncentral hypergeometric distribution. The proposed algorithms are implemented in a Java class Hypergeometric that provides methods (routines) for computing the probability mass, the cumulative distribution, the mean and variance, and for generating random deviates. The routines for computing the mean and variance are useful for estimating the odds ratio via maximum likelihood (McCullagh and Nelder 1989, chap. 7), and the routines for the probability mass and cumulative distribution facilitate the construction of confidence intervals and power calculation of associated tests (Vollset, Hirji, and Elash-hoff 1991). The routines for generating random deviates can be used in simulation-based methods for inference in more complicated problems (McDonald, Smith, and Forster 1999). The algorithms use a recursive relation to avoid the expensive and explosive combinatorial numbers. The algorithms also take advantage of the sharp concentratio n of the distribution around its mode in order to save computing time. A modified inverse method is developed for generating random deviates. We hope to dispel the perception that, except when the margins are small, the computation of the distribution is difficult (see McCullagh and Nelder 1989, p. 259; Breslow and Cologne 1986; McDonald, Smith, and Forster 1999). These perceived difficulties led to the development of special algorithms for computing the mean and variance of the distribution that avoid computing the probability distribution (Satten and Kupper 1990; Liao 1992). …

• Questia's entire collection
• Automatic bibliography creation
• More helpful research tools like notes, citations, and highlights

If you are trying to select text to create highlights or citations, remember that you must now click or tap on the first word, and then click or tap on the last word.
One moment ...
Default project is now your active project.
Project items

Highlights (0)
Some of your highlights are legacy items.
Citations (0)
Some of your citations are legacy items.
Notes (0)
Bookmarks (0)

Project items include:
• Saved book/article
• Highlights
• Quotes/citations
• Notes
• Bookmarks
Notes

#### Cited article

Style
Citations are available only to our active members.
Sign up now to cite pages or passages in MLA, APA and Chicago citation styles.

(Einhorn, 1992, p. 25)

(Einhorn 25)

1

1. Lois J. Einhorn, Abraham Lincoln, the Orator: Penetrating the Lincoln Legend (Westport, CT: Greenwood Press, 1992), 25, http://www.questia.com/read/27419298.

#### Cited article

Fast and Stable Algorithms for Computing and Sampling from the Noncentral Hypergeometric Distribution
Settings

#### Settings

Typeface
Text size Reset View mode
Search within

Look up

#### Look up a word

• Dictionary
• Thesaurus
Please submit a word or phrase above.

Why can't I print more than one page at a time?

Full screen

## Cited passage

Style
Citations are available only to our active members.
Sign up now to cite pages or passages in MLA, APA and Chicago citation styles.

"Portraying himself as an honest, ordinary person helped Lincoln identify with his audiences." (Einhorn, 1992, p. 25).

"Portraying himself as an honest, ordinary person helped Lincoln identify with his audiences." (Einhorn 25)

"Portraying himself as an honest, ordinary person helped Lincoln identify with his audiences."1

1. Lois J. Einhorn, Abraham Lincoln, the Orator: Penetrating the Lincoln Legend (Westport, CT: Greenwood Press, 1992), 25, http://www.questia.com/read/27419298.

## Welcome to the new Questia Reader

The Questia Reader has been updated to provide you with an even better online reading experience.  It is now 100% Responsive, which means you can read our books and articles on any sized device you wish.  All of your favorite tools like notes, highlights, and citations are still here, but the way you select text has been updated to be easier to use, especially on touchscreen devices.  Here's how:

1. Click or tap the first word you want to select.
2. Click or tap the last word you want to select.

## Thanks for trying Questia!

Please continue trying out our research tools, but please note, full functionality is available only to our active members.

Your work will be lost once you leave this Web page.