Created
December 30, 2022 09:11
-
-
Save joaorbrandao/4e31d43f5fd3f43d1890e64c69d3a8c0 to your computer and use it in GitHub Desktop.
Percentil calculations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun List<Long>.p50(): Long { | |
val sorted = sorted() | |
val p50Position = floor(sorted.size * 0.5).toInt() | |
return sorted[p50Position] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun List<Long>.p90(): Long { | |
val sorted = sorted() | |
val p90Position = floor(sorted.size * 0.9).toInt() | |
return sorted[p90Position] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun List<Long>.p99(): Long { | |
val sorted = sorted() | |
val p99Position = floor(sorted.size * 0.99).toInt() | |
return sorted[p99Position] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment