indexOfMedian

internal fun <T : Comparable<T & Any>?> Sequence<T>.indexOfMedian(type: KType, skipNaN: Boolean): Int

Returns the index of the median in the comparable input:

  • -1 if empty or all null

  • index of first NaN if skipNaN is false and contains NaN

  • index (lower) middle else NOTE: For primitive numbers the seq.elementAt(seq.indexOfMedian()) might be different from seq.medianOrNull()

Based on quantile implementation; uses QuantileEstimationMethod.R3.