Functions


PROBHYPR Function

Subsections:

computes the probability that an observation from a hypergeometric distribution is less than or equal to x.

Syntax

PROBHYPR$(N,K,n,x<,r>)$

where

N

is the population size for a hypergeometric distribution. In terms of acceptance sampling, N is the lot size.

K

is the number of items in the category of interest in the population. In terms of acceptance sampling, K is the number of nonconforming items in a lot.

n

is the sample size for a hypergeometric distribution. In terms of acceptance sampling, n is the sample size.

x

is the number of items from the category of interest in the sample. In terms of acceptance sampling, x is the number of nonconforming items in the sample.

r

is optional and gives the odds ratio for the extended hypergeometric distribution. For the standard hypergeometric distribution, r = 1; this value is the default. In acceptance sampling, typically r = 1.

Restrictions on items in the syntax are given in the following equations:

\[ \begin{array}{l} 1\leq N \\ 0\leq K\leq N \\ 0\leq n\leq N \\ \max (0,K+n-N)\leq x\leq \min (K,n) \\ N, K, n \mbox{ and } x \mbox{ are integers } \end{array} \]

Description

The PROBHYPR function returns the probability that an observation from an extended hypergeometric distribution with parameters N, K and n and an odds ratio of r is less than or equal to x. The default for r is 1 and leads to the usual hypergeometric distribution.

In terms of acceptance sampling, if r = 1, the PROBHYPR function gives the probability of x or fewer nonconforming items in a sample of size n taken from a lot containing N items, K of which are nonconforming, when sampling is done without replacement. Typically r = 1 in acceptance sampling.

For example, suppose an urn contains red and white balls, and you are interested in the probability of selecting a white ball. If r = 1, the function returns the probability of selecting x white balls when given the population size (number of balls in the urn), sample size (number of balls taken from the urn), and number of white balls in the population (urn).

If, however, the probability of selecting a white ball differs from the probability of selecting a red ball, then $r\neq 1$. Suppose an urn contains one white ball and one red ball, and the probability of choosing the red ball is higher than the probability of choosing the white ball. This might occur if the red ball were larger than the white ball, for example. Given the probabilities of choosing a red ball and a white ball when an urn contains one of each, you calculate r and use the value in the PROBHYPR function. Returning to the case where an urn contains many balls with $r\neq 1$, the function gives the probability of selecting x white balls when given the number of balls in the urn, the number of balls taken from the urn, the number of white balls in the urn, and the relative probability of selecting a white ball or a red ball.

The PROBHYPR function is used to evaluate Type A single-sampling plans. See Evaluating Single-Sampling Plans for details.

If r = 1 (the default), the PROBHYPR function calculates probabilities from the usual hypergeometric distribution:

\[ \mbox{Pr}[X\leq x]=\sum _{i=0}^ x P_ i \]

where

\[ P_ i= \left\{ \begin{array}{cl} \frac{ \left( \begin{array}{c} K \\ i \end{array} \right) \left( \begin{array}{c} N-K \\ n-i \end{array} \right) }{ \left( \begin{array}{c} N \\ n \end{array} \right) } & \mbox{if }\max (0,K+n-N)\leq i \leq \min (K,n) \\[0.5in] 0 & \mbox{otherwise} \end{array} \right. \]

The PROBHYPR function accepts values other than 1 for r, and in these cases, it calculates the probability for the extended hypergeometric distribution:

\[ \Pr [X_1\leq x | X_1+X_2 = n ] = \sum _{i=o}^ x P_ i \]

where

\[ P_ i= \left\{ \begin{array}{cl} \frac{ \left( \begin{array}{c} K \\ i \end{array} \right) \left( \begin{array}{c} N-K \\ n-i \end{array} \right) {\displaystyle r^ j} }{ {\displaystyle \sum _{j=0}^ n} \left( \begin{array}{c} K \\ j \end{array} \right) \left( \begin{array}{c} N-K \\ n-j \end{array} \right) {\displaystyle r^ j} } & \mbox{if }\max (0,K+n-N)\leq i \leq \min (K,n) \\[0.5in] 0 & \mbox{otherwise} \end{array} \right. \]

where

$X_1$

is binomially distributed with parameters K and $p_1$.

$X_2$

is binomially distributed with parameters N-K and $p_2$.

$q_1$

$=1-p_1$

$q_2$

$=1-p_2$

r

$=(p_1q_2)/(p_2q_1)$

For details on the extended hypergeometric distribution, refer to Johnson and Kotz (1969).

Examples

Suppose you take a sample of size 10 (without replacement) from an urn that contains 200 balls, 50 of which are white. The remaining 150 balls are red. The following statements calculate the probability that your sample contains 2 or fewer white balls:

data;
   y=probhypr(200,50,10,2);
   put y;
run;

These statements result in a value of 0.5236734081. Now, suppose the probability of selecting a red ball does not equal the probability of selecting a white ball. Specifically, suppose the probability of choosing a red ball is $p_2=0.4$ and the probability of choosing a white ball is $p_1=0.2$. Calculate r as

\[ r = \frac{p_1q_2}{p_2q_1} = \frac{(0.2)(0.6)}{(0.4)(0.8)} = 0.375 \]

With r = 0.375, the probability of choosing 2 or fewer white balls from an urn that contains 200 balls, 50 of which are white, is calculated using the following statements:

data;
   y=probhypr(200,50,10,2,0.375);
   put y;
run;

These statements return a value of 0.9053936127. See Evaluating Single-Sampling Plans for another example.

For additional information on probability functions, refer to SAS Functions and CALL Routines: Reference.