Main Content

hygecdf

Hypergeometric cumulative distribution function

Description

p = hygecdf(x,m,k,n) returns the cumulative distribution function (cdf) of the hypergeometric distribution, evaluated at the values in x, using the corresponding size of the population m, the number of items with the intended characteristic in the population, k and the number of items drawn n.

example

p = hygecdf(x,m,k,n,"upper") returns the complement of the cdf, evaluated at the values in x, using an algorithm that more accurately computes the extreme upper-tail probabilities.

example

Examples

collapse all

Determine the probability of sampling a defective machine part from a population by using the hygecdf function.

Suppose that a warehouse contains 100 machine parts, 20 of which are known to be defective, and you collect a sample of 10 different parts from the warehouse at random. Determine the probability of finding between 0 and x defective parts in your sample, for integer values of x between 0 and 8.

x = 0:1:8;
m = 100;
k = 20;
n = 10;
p = hygecdf(x,m,k,n)
p = 1×9

    0.0951    0.3630    0.6812    0.8904    0.9745    0.9961    0.9996    1.0000    1.0000

Plot the probabilities.

plot(x,p,"o",MarkerFaceColor="b")
ylabel("p")
xlabel("x")

Figure contains an axes object. The axes object with xlabel x, ylabel p contains a line object which displays its values using only markers.

The probability of finding between 0 and x defective parts in your sample approaches 1 when x > 4.

Compute the extreme upper-tail probability values with greater precision by computing the complement of the cdf directly.

p2 = hygecdf([7 8],m,k,n,"upper")
p2 = 1×2
10-4 ×

    0.2378    0.0079

The values of p2 are equal to 1 minus the probability of finding between 0 and 7 defective parts, and 0 and 8 defective parts, respectively.

Input Arguments

collapse all

Values at which to evaluate the hypergeometric cdf, specified as a nonnegative scalar value or an array of nonnegative scalar values. Each value in x must be less than or equal to the corresponding values in m, n, and k.

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs of multiple distributions, specify m, k, and n using arrays. If one or more of the input arguments x, m, k, and n are arrays, then the array sizes must be the same. In this case, hygecdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in m, k, and n, evaluated at the corresponding element in x.

Data Types: single | double

Size of the population, specified as a nonnegative integer or an array of nonnegative integers. Each value in m must be greater than or equal to the corresponding values in n and k.

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs of multiple distributions, specify m, k, and n using arrays. If one or more of the input arguments x, m, k, and n are arrays, then the array sizes must be the same. In this case, hygecdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in m, k, and n, evaluated at the corresponding element in x.

Data Types: single | double

Number of items with intended characteristics in the population, specified as a nonnegative integer or an array of nonnegative integers. Each value in k must be less than or equal to the corresponding value in m.

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs of multiple distributions, specify m, k, and n using arrays. If one or more of the input arguments x, m, k, and n are arrays, then the array sizes must be the same. In this case, hygecdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in m, k, and n, evaluated at the corresponding element in x.

Data Types: single | double

Number of items drawn from the population, specified as a nonnegative integer or an array of nonnegative integers. Each value in n must be less than or equal to the corresponding value in m.

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs of multiple distributions, specify m, k, and n using arrays. If one or more of the input arguments x, m, k, and n are arrays, then the array sizes must be the same. In this case, hygecdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in m, k, and n, evaluated at the corresponding element in x.

Data Types: single | double

Output Arguments

collapse all

Hypergeometric cdf values, returned as a scalar value or an array of scalar values. p is the same size as x, m, k, and n after any necessary scalar expansion. Each element in p is the cdf value of the distribution specified by the corresponding elements in m, k, and n, evaluated at the corresponding element in x.

More About

collapse all

Alternative Functionality

  • hygecdf is a function specific to the hypergeometric distribution. Statistics and Machine Learning Toolbox™ also offers the generic function cdf, which supports various probability distributions. To use cdf, specify the probability distribution name and its parameters. Note that the distribution-specific function hygecdf is faster than the generic function cdf.

  • Use the Probability Distribution Function Tool to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a