random_partition.pl -- random paritioning of a set of interpretations

An "almost linear" algorithm for random partitioning.

Usage
?- use_module(random_partition).

?- random_partition([1, 2, 3, 4], 2, Groups). Groups = [[3,1],[4,2]]

?- random_partition([1, 2, 3, 4], 2, Groups). Groups = [[4,3],[2,1]]

?- random_partition([1, 2, 3, 4], 3, Groups). Groups = [[3],[2],[4,1]]

Algorithm
Predicate divide2/5 picks a random bucket number. If the bucket is full, then it goes to the right in search of a non-full bucket. Predicate random_partition/3 proceeds in 2 steps: first, it randomly throws elements in buckets with max capacity #Models/#Buckets then the remaining models are thrown onto buckets randomly.

This module originates from ACE but was significantly modified for kLog.

Results
The produced partitions are unordered.
author
- Jan Struyf, Kurt De Grave

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

random_partition_stratified(Arg1, Arg2, Arg3, Arg4)
random_partition(Arg1, Arg2, Arg3)