Skip to content

Commit

Permalink
Calculate a minimal deviation to catch at least one game inside the d…
Browse files Browse the repository at this point in the history
…eviation range
  • Loading branch information
timoschwarzer committed Jul 2, 2024
1 parent d9ea2af commit c827dfa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/kotlin/wotw/server/database/model/LeagueSeason.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,20 @@ class LeagueSeason(id: EntityID<Long>) : LongEntity(id) {
submissionsWithATime.sumOf { (it.points - averagePoints).pow(2) } / submissionsWithATime.size
} else 0.0

val standardDeviation = sqrt(variance)
// We don't want that all submissions lie outside the standard
// deviation.
val minimalDeviation = if (submissionsWithATime.isNotEmpty()) {
submissionsWithATime.minOf { abs(it.points - averagePoints) } + 1.0
} else 1.0

// Max of standard deviation and minimal deviation to catch at least one game
val deviationRange = max(sqrt(variance), minimalDeviation)

val discardingSubmissionWeights = mutableMapOf<LeagueGameSubmission, Double>()

submissions.take(worstSubmissionsToDiscardCount).forEach { submission ->
discardingSubmissionWeights[submission] = if (submission.time != null) {
max(0.01, 1.0 - abs(submission.points - averagePoints) / max(standardDeviation, 1.0))
max(0.0, 1.0 - abs(submission.points - averagePoints) / deviationRange)
} else 0.0
}

Expand Down

0 comments on commit c827dfa

Please sign in to comment.