Main Content

hygepdf

Hypergeometric probability density function

Description

p = hygepdf(x,m,k,n) returns the probability density function (pdf) 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

Examples

collapse all

Determine the probability of sampling a specific number of defective machine parts from a population by using the hypergeometric probability density 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 exactly x defective parts in your sample, for values of x ranging from 0 to 10.

m = 100;
k = 20;
n = 10;
x = 0:1:10;
p = hygepdf(x,m,k,n);

Plot the probabilities as a function of x. Use blue circle markers.

plot(x,p,"o",MarkerFaceColor="b")
grid on
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 plot indicates that the highest probability corresponds to finding two defective parts.

Input Arguments

collapse all

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

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs 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, hygepdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf at multiple values, specify x using an array. To evaluate the pdfs 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, hygepdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf at multiple values, specify x using an array. To evaluate the pdfs 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, hygepdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf at multiple values, specify x using an array. To evaluate the pdfs 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, hygepdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf values, returned as a numeric scalar or array. p is the same size as x, m, k, and n after any necessary scalar expansion. Each element in p is the pdf 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

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

  • 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