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

View source: R/utils.R

all_multinomR Documentation

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)

Arguments

n

Number of indistinguishable balls.

k

Number of distinguishable bins.

Value

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

Author(s)

David Gerard

Examples

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


hwep documentation built on May 31, 2023, 9:06 p.m.