bin

Groups the values into equal-width bins of the given binSize.

This is a convenience wrapper around binByDouble for collections of raw Double values.

Example:

listOf(1.0, 2.0, 3.0, 4.0, 5.0).bin(2.5)
// 2 bins: [1.0..3.5] and [3.5..6.0]

Return

a list of Bin objects containing the values that fall within each range.

Parameters

binSize

the width of each bin. Must be positive.


fun Iterable<Double>.bin(binCount: Int): List<Bin<Double>>(source)

Groups the values into a fixed number of equal-width bins.

This is a convenience wrapper around binByDouble for collections of raw Double values.

Example:

listOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0).bin(3)
// 3 bins spanning the range [1.0, 10.0]

Return

a list of Bin objects containing the values that fall within each range.

Parameters

binCount

the desired number of bins. Must be positive.


Groups the values into equal-width bins of the given binSize.

This is a convenience overload that accepts a DoubleArray. The array is converted to a list internally.

Return

a list of Bin objects containing the values that fall within each range.

Parameters

binSize

the width of each bin. Must be positive.

See also


fun DoubleArray.bin(binCount: Int): List<Bin<Double>>(source)

Groups the values into a fixed number of equal-width bins.

This is a convenience overload that accepts a DoubleArray. The array is converted to a list internally.

Return

a list of Bin objects containing the values that fall within each range.

Parameters

binCount

the desired number of bins. Must be positive.

See also