AdmissibilityCertificate

class AdmissibilityCertificate(sortedData: DoubleArray, val minimumGroupSize: Int = defaultMinimumGroupSize, val minimumDistinctValues: Int = defaultMinimumDistinctValues)(source)

Structural facts about a sorted sample that determine which partitions can exist, computed once in O(n) and reused by every partition generator, refiner, and search over that sample.

The purpose is prevention rather than handling. Several conditions that would otherwise have to be detected and recovered from inside the fitting loop are properties of the data and the configuration alone, so they can be decided up front and the offending configurations simply refused. In particular, if the number of components is restricted to be no greater than maximumFeasibleGroups, then no partition search can be handed an infeasible problem.

Three structural constraints are represented:

  1. A cut may not split a run of equal values. A partition is defined by value intervals, so tied observations must stay together. The permissible cut positions are the block boundaries, available as admissibleCuts.

  2. Every group must contain at least minimumGroupSize observations.

  3. Every group must contain at least minimumDistinctValues distinct values. A group whose observations are all equal has zero sample variance and admits no finite normal or lognormal maximum likelihood estimate, so a value of 2 excludes that failure by construction rather than by catching it later.

Parameters

sortedData

the observations in non-decreasing order, must not be empty. The array is not retained; only structural summaries are kept.

minimumGroupSize

the least number of observations permitted in a group, must be positive

minimumDistinctValues

the least number of distinct values permitted in a group, must be positive

Constructors

Link copied to clipboard
constructor(sortedData: DoubleArray, minimumGroupSize: Int = defaultMinimumGroupSize, minimumDistinctValues: Int = defaultMinimumDistinctValues)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The positions at which a cut may be placed without splitting a run of equal values, in increasing order. The first element is always 0 and the last is always the number of observations; these two are the outer boundaries rather than interior cuts.

Link copied to clipboard

The largest number of groups for which some partition of this sample satisfies all three structural constraints.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The number of distinct values in the whole sample.

Link copied to clipboard

The number of observations summarized by this certificate.

Functions

Link copied to clipboard
fun distinctCount(start: Int, end: Int): Int

The number of distinct values within the index range from start until end. This is exact only when both endpoints are admissible cut positions, because otherwise a run of equal values straddles the boundary and is counted on one side only.

Link copied to clipboard
fun distinctPrefix(index: Int): Int

The number of distinct values among the first index observations.

Link copied to clipboard

Restricts a requested range of group counts to those that are structurally feasible for this sample. Searching only over the returned values guarantees that no partition search is ever handed an infeasible problem.

Link copied to clipboard
fun infeasibilityReason(numGroups: Int): String?

Explains why the supplied number of groups is not feasible, or null when it is feasible. Intended for diagnostics recorded alongside experimental results, so that a case excluded by structure is distinguishable from one that failed for a numerical reason.

Link copied to clipboard
fun isAdmissibleCut(position: Int): Boolean

Indicates whether a cut at the supplied position would split a run of equal values. Positions 0 and the number of observations are treated as admissible boundaries.

Link copied to clipboard
fun isFeasible(numGroups: Int): Boolean

Indicates whether a partition of this sample into the supplied number of groups exists that satisfies all three structural constraints.

Link copied to clipboard
fun isValidGroup(start: Int, end: Int): Boolean

Indicates whether the index range from start until end satisfies the size and distinct-value requirements for a group.

Link copied to clipboard
open override fun toString(): String