Learn R Programming

rpartitions (version 0.1)

P: Number of partitions of Q with k or less parts.

Description

This function was derived using the following theorem and proposition. The number of partitions of Q with k or less parts equals the number of partitions of Q with k or less as the largest part (see Bona 2006). This is a mathematical symmetry, i.e. congruency. Additionally, the number of partitions of Q with k or less parts equals the number of partitions of Q+k with k as the largest part when k>0, i.e. P(Q + k, k). We do not have a source for this proposition, but it can be shown when enumerating the entire feasible set or using the Sage computing enviornment

Usage

P(D, Q, k, use_c, use_hash)

Arguments

D
lookup table for numbers of partitions of Q having k or less parts (or k or less as the largest part), i.e. P(Q, Q + k)
Q
total (i.e., sum across all k or n parts)
k
the number of parts and also the size of the largest part (congruency)
use_c
boolean, if TRUE the number of partitions is computed in c
use_hash
boolean, if TRUE then a hash table is used instead of R's native list to store the information

Value

a two element list, the first element is D the lookup table and the second element is the number of partitions for the specified Q and k value.

References

Bona, M. (2006). A Walk Through Combinatorics: An Introduction to Enumeration and Graph Theory. 2nd Ed. World Scientific Publishing Co. Singapore.

Examples

Run this code
P(list(), 100, 10, FALSE, FALSE)

Run the code above in your browser using DataLab