I am consulting with a mathematician, and will make sure this is fixed accordingly.
🐝 ☕ bug (he/him) | your friendly neighborhood code wrangler. stay in the loop! join and check out the latest admin post highlights
I have chosen to change this page to show the probability rather than the odds for the following reasons:
For those who are curious, here's some info on the accurate calculations. For both, I will assume we have n potions, and I will use t[sub]n[/sub] to represent the total number of tickets purchased for potion [i]n, and b[sub]n[/sub] to represent the number of tickets purchased for potion [i]n by the current user.
Calculating the Odds To calculate the odds, you would need to sum (b[sub]n[/sub] / t[sub]n[/sub]) for all n. However, you need to keep them in fractional form while doing so, which is where a rational arithmetic library would be helpful. The resulting sum is then divided by n the number of potions. Your final result would be a rational number written as a fraction m/n. From there, the odds would be equal to m : (n - m).
Calculating the Probability This one is so much easier. Like the odds, sum (b[sub]n[/sub] / t[sub]n[/sub]) for all n, and then divide by n. However in this case it's okay if the number is a decimal form. You can simply multiple it by 100 (and do a little rounding to make it nice) to get your percentage.
🐝 ☕ bug (he/him) | your friendly neighborhood code wrangler. stay in the loop! join and check out the latest admin post highlights
Your method is incorrect because you haven't proved it will result in whole numbers. Dividing each side by the smaller number will rarely work, for instance, try that method with the ratio 5 to 3.5 Divide both by 3.5 and you just get 5/3.5 to 1.
🐝 ☕ bug (he/him) | your friendly neighborhood code wrangler. stay in the loop! join and check out the latest admin post highlights
Anyway, locking as it's been fixed.
🐝 ☕ bug (he/him) | your friendly neighborhood code wrangler. stay in the loop! join and check out the latest admin post highlights