主要内容

hygestat

Hypergeometric mean and variance

Description

mu = hygestat(m,k,n) returns the mean for the hypergeometric distribution with the size of the population m, the number of items with the intended characteristic in the population k, and the number of items drawn n.

[mu,sigma] = hygestat(m,k,n) also returns the variance for the distribution.

example

Examples

collapse all

Compute the mean and variance of a hypergeometric distribution with the population size m, number of items with intended characteristics in the population k, and number of items drawn from the population n.

m = 100;
k = 5;
n = 3;
[mean,variance] = hygestat(m,k,n)
mean = 
0.1500
variance = 
0.1396

Input Arguments

collapse all

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. If one or more of the input arguments m, k, and n are arrays, then the array sizes must be the same. In this case, hygestat expands each scalar input into a constant array of the same size as the array inputs.

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. If one or more of the input arguments m, k, and n are arrays, then the array sizes must be the same. In this case, hygestat expands each scalar input into a constant array of the same size as the array inputs.

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. If one or more of the input arguments m, k, and n are arrays, then the array sizes must be the same. In this case, hygestat expands each scalar input into a constant array of the same size as the array inputs.

Data Types: single | double

Output Arguments

collapse all

Mean for the hypergeometric distribution, returned as a numeric scalar or an array of numeric scalars. mu is the same size as m, k, and n. Each element in mu is the mean of the hypergeometric distribution specified by the corresponding elements in m, k, and n. The mean of the hypergeometric distribution is nk/m.

Variance for the hypergeometric distribution, returned as a numeric scalar or an array of numeric scalars. sigma is the same size as m, k, and n. Each element in sigma is the variance of the hypergeometric distribution specified by the corresponding elements in m, k, and n. The variance of the hypergeometric distribution is nk(m – k)(m – n)/[m^2(m – 1)].

Extended Capabilities

expand all

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

Version History

Introduced before R2006a