Learn R Programming

hwep (version 2.0.3)

all_multinom: Get every possible non-negative tuple with of a given sum.

Description

The total number of rows is choose(n = k + n - 1, k = k - 1). This function uses recursion, so is not the most efficient.

Usage

all_multinom(n, k)

Value

A matrix, rows index different possible multinomial counts, the columns index the bins.

Arguments

n

Number of indistinguishable balls.

k

Number of distinguishable bins.

Author

David Gerard

Examples

Run this code
n <- 5
k <- 3
all_multinom(n = n, k = k)
choose(n = n + k - 1, k = k - 1)

Run the code above in your browser using DataLab