Learn R Programming

xegaDerivationTrees (version 1.0.0.6)

rndPartition: Randomly partitions n in k parts.

Description

Sampling a partition is a two-step process:

  1. The k parts of the partion are sampled in the loop. This implies that the first partition p is a random number between 1 and 1+n-k. The next partition is sampled from 1 to 1+n-k-p.

  2. We permute the partitions.

Usage

rndPartition(n, k)

Value

The integer partition of n in k parts.

Arguments

n

The integer to divide.

k

Number of parts.

Examples

Run this code
 rndPartition(10, 4)

Run the code above in your browser using DataLab