Data Partition
An immutable contiguous partition of sorted data into k groups, represented by the interior cut positions rather than by copying the data.
A partition of n observations into k groups is determined by k-1 interior cuts 0 < t(1) < t(2) < ... < t(k-1) < n, with group j occupying the half-open index range (t(j-1), t(j)] in 1-based terms, or indices t(j-1) until t(j) in 0-based terms, where t(0) = 0 and t(k) = n.
No observation data is held or copied. Groups are described by index ranges into the caller's sorted array, which makes a partition cheap to create, compare, and use as a cache key. This matters because the refinement loop creates many partitions that differ in only one cut.
Instances are immutable. Derived partitions are produced by the functions that return a new instance rather than by mutation.
Parameters
the number n of observations being partitioned, must be positive
the k-1 interior cut positions, strictly increasing and within (0, n)
Properties
A defensive copy of the interior cut positions, in increasing order.
The sizes of all groups, in group order. The elements sum to the number of observations.
The smallest group size in the partition.
The empirical group proportions, in group order. These are the natural initial mixing weights: proportion j is the fraction of the sample assigned to group j. The elements sum to 1.0.
Functions
Returns a copy of the observations assigned to the supplied group. This allocates, and is intended for handing a group to an estimator. Prefer the index accessors when only the range is needed.
The inclusive starting index, into the sorted data, of the group with the supplied zero-based index.
Returns a new partition with the cut at the supplied index moved to a new position. The receiver is not modified. The resulting cut positions must remain strictly increasing and within the data, otherwise an exception is thrown.