Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

auxfun

Auxiliary functions for 'randtoolbox' package.


Description

Stirling numbers of the second kind and permutation of positive integers.

Usage

stirling(n)
permut(n)

Arguments

n

a positive integer.

Details

stirling computes stirling numbers of second kind i.e.

Stirl_n^k = k * Stirl_{n-1}^k + Stirl_{n-1}^{k-1}

with Stirl_n^1 = Stirl_n^n = 1. e.g.

  • n = 0, returns 1

  • n = 1, returns a vector with 0,1

  • n = 2, returns a vector with 0,1,1

  • n = 3, returns a vector with 0,1,3,1

  • n = 4, returns a vector with 0,1,7,6,1...

Go to wikipedia for more details.

permut compute permutation of {1, ..., n} and store it in a matrix. e.g.

  • n=1, returns a matrix with

    1
  • n=2, returns a matrix with

    1 2
    2 1
  • n=3 returns a matrix with

    3 1 2
    3 2 1
    1 3 2
    2 3 1
    1 2 3
    2 1 3

Value

a vector with stirling numbers.

Author(s)

Christophe Dutang.

See Also

choose for combination numbers.

Examples

# should be 1
stirling(0)

#  should be 0,1,7,6,1
stirling(4)

randtoolbox

Toolbox for Pseudo and Quasi Random Number Generation and Random Generator Tests

v1.30.1
BSD_3_clause + file LICENSE
Authors
R port by Yohan Chalabi, Christophe Dutang, Petr Savicky and Diethelm Wuertz with some underlying C codes of (i) the SFMT algorithm from M. Matsumoto and M. Saito, (ii) the Knuth-TAOCP RNG from D. Knuth.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.