five--three
Skeletron
I've still got a couple of years in school so I'm not up to this level of maths yet. It is definitely my favourite subject though, so this is really interesting to meYes, those calculations look good for determining probability of 3 bosses being fought within X day/night cycles. However, I was referring to the EV, which is more useful because it indicates how many cycles on average you'd be expected to wait before encountering all 3 bosses. Since the EV is the the probability-weighted average of all outcomes, I believe the calculation would go like this:
EV=3(1/10)^3 + 4(3C2)(1/10)^3(9/10) + 5(4C2)(1/10)^3(9/10)^2 + ... + n[(n-1)C2)(1/10)^3(9/10)^(n-3) where n is a very large number
The xCy function is the combination function. The 3, 4, 5 etc at the start of each term in the series refers to the number of day/night cycles and each of these numbers is multiplied by the probability of getting 3 mech bosses to spawn in exactly that many cycles. The probability of getting 3 boss fights in exactly n days is:
[(n-1)C2]*[(1/10)^3]*[(9/10)^(n-3)]
which simplifies to:
(1/2000)*(n-1)*(n-2)*(9/10)^(n-3)
The reason I'm using (n-1)C2 for the number of arrangements of 3 nights with boss spawns and n-3 nights (and not nC3) without boss spawns is because the 3rd boss spawn must always fall on the nth night.
So now we need to calculate this infinite sum:
EV=SUM(from n=3 to inf) n*(1/2000)*(n-1)*(n-2)*(9/10)^(n-3)
Let's bust out an online calculator:
http://www.wolframalpha.com/widget/widgetPopup.jsp?p=v&id=29c546473e1c796d6076bb18901b15e7&title=Infinite Series Calculator&theme=blue&i0=n*[(9/10)^(n-3)]*n!/(n-3)!/6000&i1=3&i2=Infinity&podSelect=&includepodid=Result&showAssumptions=1&showWarnings=1
The sum is 30, which makes sense since there is a 1/10 chance each day of getting a boss summon. In other words, the player will wait on average for 30 day/night cycles (or 12 hours) for all 3 mech bosses to spawn, assuming the calculations are correct.
Fingers crossed that you'll live the next time .
Just to muck around, I threw this together and tried to work it out ...
Code:
import math
#Combination function
def nCr(n,r):
return (math.factorial(n))/(math.factorial(r)*math.factorial(n-r))
stringToEvaluate = ""
for i in range(3, 100):
#Loop through this multiple times (starting at i=3, finishing at i=99)
x = str(i) #String representation of i
s = x + " * (nCr(" + x + ", 3) * (0.1)) ** (3 * (0.9**" + str(i-3) + ")) +"
stringToEvaluate += s
print(s)
#Note: x**y is python for x^y. The ^ operator is used for XOR.
stringToEvaluate += "0" # Add a "0" to the string, to handle the extra plus at the end
print(stringToEvaluate)
print(eval(stringToEvaluate)) #Evaluate the result and print to console.
This gives me some nice-looking results like
3 * (nCr(3, 3) * (0.1)) ** (3 * (0.9**0)) +
4 * (nCr(4, 3) * (0.1)) ** (3 * (0.9**1)) +
5 * (nCr(5, 3) * (0.1)) ** (3 * (0.9**2)) +
... all the way up to 99 * (nCr(99, 3) * (0.1)) ** (3 * (0.9**96))
But, when evaluating all of these and adding together, I get 10672.056. I've tried removing the brackets (e.g. 3 * nCr(3, 3) * 0.1 ** 3 * 0.9**0), as I'm not entirely sure what the intended formula is, and I got the slightly more reasonable result of 381.2289.
What am I doing wrong? My understanding was that the result would get infinitely closer to the actual EV with each sucessive calculaation added. Since infinity seems to be a little bit big, I'm only doing 97 loops instead on the assumption that I would get close enough to infer the actual answer (e.g. 49.998).
Edit: whoops! I didn't see that you had taken it on! I didn't know wolfram could do that either I'll take a look at your math and learn something from it
Edit 2: That's making a bit more sense now that I read what you did.
I'vee been playing around with my script a bit more, and by evaluating the command on each loop I get something interesting ...
I think I know what to do now ...
Last edited: