Next: , Previous: The Binomial Distribution, Up: Random Number Distributions


19.32 The Multinomial Distribution

— Function: void gsl_ran_multinomial (const gsl_rng * r, size_t K, unsigned int N, const double p[], unsigned int n[])

This function returns an array of K random variates from a multinomial distribution. The distribution function is,

          P(n_1, n_2, ..., n_K) =
            (N!/(n_1! n_2! ... n_K!)) p_1^n_1 p_2^n_2 ... p_K^n_K

where (n_1, n_2, ..., n_K) are nonnegative integers with sum_{k=1}^K n_k = N, and (p_1, p_2, ..., p_K) is a probability distribution with \sum p_i = 1. If the array p[K] is not normalized then its entries will be treated as weights and normalized appropriately.

Random variates are generated using the conditional binomial method (see C.S. David, The computer generation of multinomial random variates, Comp. Stat. Data Anal. 16 (1993) 205–217 for details).

— Function: double gsl_ran_multinomial_pdf (size_t K, const double p[], const unsigned int n[])

This function computes the probability P(n_1, n_2, ..., n_K) of sampling n[K] from a multinomial distribution with parameters p[K], using the formula given above.

— Function: double gsl_ran_multinomial_lnpdf (size_t K, const double p[], const unsigned int n[])

This function returns the logarithm of the probability for the multinomial distribution P(n_1, n_2, ..., n_K) with parameters p[K].