Created
August 21, 2025 10:38
-
-
Save cmelchior/5416c26b4745536d2b2db17faf42dacc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ps: Probability array of "success" for each roll | |
fun luckSymExact(ps: List<Double>, successes: Int): Double { | |
// Check for all fail/succeed case, since this will reported wrong otherwise | |
val variance = ps.sumOf { it * (1 - it) } | |
if (variance == 0.0) { | |
return when (successes > 0) { | |
true -> 100.0 | |
false -> -100.0 | |
} | |
} | |
val pmf = pbPmf(ps) | |
val mid = midCdf(pmf, successes) // in [0,1] | |
return (2.0 * mid - 1.0) * 100.0 // in [-100,+100] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment