https://kotlinlang.org logo
#datascience
Title
# datascience
h

hudsonb

02/01/2019, 1:56 PM
@thomasnield just read your intro article on kotlin-statistics. I whipped up some extensions on
BinModel
which allow this:
Copy code
val avgWbccByAgeRange = patients.binByInt(valueSelector = { it.age }, binSize = 10, rangeStart = 20)
                                .averageByInt { it.whiteBloodCellCount }
For comparison, the article uses:
Copy code
val avgWbccByAgeRange = patients.binByInt(
        valueSelector = { it.age },
        binSize = 10,
        rangeStart = 20,
        groupOp = { it.map { it.whiteBloodCellCount }.average() }
)
I'll put together a PR if you're interested.