bellpoly: Evaluate partial Bell polynomials

Description Usage Arguments Value Examples

View source: R/bellpoly.R

Description

Evaluates the partial Bell polynomials, also known as the incomplete Bell polynomials. The complete Bell polynomial is the sum of the partial Bell polynomials over k=1,…,n. The partial polynomials are evaluted using the recurrence relation

k B_{n,k}(x_1,…,x_{n-k+1}) = ∑_{r=k-1}^{n-1} choose(n,r)x_{n-r}B_{r,k-1}(x_1,…,x_{r-k+2})

with B_{0,0} = 1, B_{0,k} = 0 for k ≥ 1, and B_{n,0} = 0 for n ≥ 1.

Usage

1
bellpoly(x, n = nrow(x), k = min(1, n):n)

Arguments

x

a matrix or object that can be coerced into one by as.matrix

n

nonnegative integer representing the number of elements

k

vector of integers no greater than n representing the sizes of partition

Value

bellpoly returns a vector or matrix depending on the dimensions of x that contains the value of the partial Bell polynomial(s) evaluated at columns of as.matrix(x).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
n <- 5
k <- 1:n

## Idempotent numbers
bellpoly(k)
choose(n, k) * k^(n - k) # equivalent

## Stirling numbers (unsigned) of the first kind
bellpoly(x = factorial(k-1))

## Stirling numbers of the second kind
bellpoly(x = rep(1, n))

kschurter/logdensity documentation built on Feb. 22, 2022, 1:07 p.m.