Vondrack asked:
Sir Ralph replied:
How to find the distribution of c from knowing c = (a + b) / 2, and knowing the distributions of a and b. We are dealing with approximately continuous variables here (they're actually discrete, like dice, but are best treated as continuous for ease of use).
Take a simple case: a single random number (a), which ranges from some value a_min to some other value a_max, and has some probability distribution f(a). The probability of finding a in some range a1 to a2 is the integral from a1 to a2[i] of f(a), as long as the integral from a_min to a_max is 1. For our pseudo-random number generator, a_min = 0, a_max = 1 and f(a) = 1 - namely we generate random numbers between 0 and 1 with each number being equally probable.
Once you average over two variables, things get more complex. A set of two random numbers from 0 to 1 can be represented as a square (each side of length 1) = the a-value runs along one side from 0 to 1, and the b-value runs along a side perpendicular to it from 0 to 1. The probability of a falling in a certain range (a_min to a_max) and b falling in a certain range (b_min to b_max) is the integral over the area defined by those limits (if we want to know the probability a is between 0.6 and 0.8 while b is between 0.15 and 0.37, we integrate over the rectangle defined by those 4 lines). In the case of uniform distributions, the probability is simply the area (once the total area is normalised to 1). Since we are interested in calculating the probability of getting a given calue of [i]c/[i], we have to integrate over the 'area' that gives that value of c - which is essentially a thin diagonal strip running from a=0, b=2c to a=2c, b=0 (for c < 0.5). This lets you calculate the probability distribution of c (which in this particular case looks like a triangle with its peak at c=0.5). The integration has to be done piecemeal - the limits you use for c < 0.5 are not valid for c > 0.5, so the integration is divided into two seperate functions.
Averaging over three variables (d = (a+b+c)/3), you have to find planes of constant 'd' within the cubic volume defined by a, b and c. The integration has to be done over three seperate cases (d < 1/3, 1/3 < d < 2/3, d > 2/3), and the final probability distribution of d is a set of three quadratic equations (one for each range of d listed above), giving something vaguely gaussian-shaped.
For four variables, yuo have to do integrations of 3-volume slices of a 4 dimensional hypercube, giving you a set of 4 cubic equations describing the probability distribution of your variable e=(a+b+c+d)/4. One cubic equation is valid over e=0..0.25, one for e=0.25..0.5, one for e=0.5..0.75 and one for e=0.75..1.0.
In combat calculator terms, you need to find out x, the unaveraged probability of the attacker winning one round of combat, and then integrate this set of cubic equations to determine the probability of actually winning of losing. Example: if the old-style probability of the attacker winning a single round was 0.586, the the probability of winning a single round in the new style would be found by integrating the first cubic from 0 to 0.25 plus the second from 0.25 to 0.5 plus the third from 0.5 to 0.586. The probability of losing would be the the integral of the third cubic from 0.586 to 0.75 plus the fourth cubic from 0.75 to 1.0. Once you have determine these new probabilities, you just plug them into an old combat calculator, using these new values as the probability of the attacker winning a single round. Once you've done the donkey work of finding the correct set of cubic equations, it's pretty straight forward, but getting those equations can be fairly tedious to do by hand, and rather prone to mistakes unless you are very careful.
Or you can do it the way I did - by simply simulating a few million combats fn each case. It is trivial to change the random number generator to generate an average of four numbers, and the results then follow quite happily.
Originally posted by vondrack
Thanks, but I would rather do my own calcs than use someone's 'blackbox'. Could you give me a hint how the probability of c=(a+b)/2 from known probabilities of a & b is calculated?
My secondary school math was enough for the old combat system (elementary combinatorics), but once this averaging thing kicks in, I am pretty much lost...
Thanks.
EDIT: Do I suspect correctly that integrals will have to be used?
Thanks, but I would rather do my own calcs than use someone's 'blackbox'. Could you give me a hint how the probability of c=(a+b)/2 from known probabilities of a & b is calculated?
My secondary school math was enough for the old combat system (elementary combinatorics), but once this averaging thing kicks in, I am pretty much lost...
Thanks.
EDIT: Do I suspect correctly that integrals will have to be used?
Sir Ralph replied:
Originally posted by Sir Ralph
You can't calculate this without knowing the distribution of the probability in form of a continuous function (i.e. how to calculate the probability of a and b depending on a third parameter). If you know this continuous function, you can calculate the probability of c the normal way (using the function).
An example: How is the probability of getting 1.5 out of a die roll, knowing that both 1 and 2 have a probability of 1/6? Nonsense, obviously, but the correct answer would be 0.
Another example: Imagine a die (cube) with two 1's, one 2 and three 3's. The probability to get a 1 is obviously 1/3, the probability of 3 is 1/2. The probability of 2 (1/6) doesn't lie between.
You can't calculate this without knowing the distribution of the probability in form of a continuous function (i.e. how to calculate the probability of a and b depending on a third parameter). If you know this continuous function, you can calculate the probability of c the normal way (using the function).
An example: How is the probability of getting 1.5 out of a die roll, knowing that both 1 and 2 have a probability of 1/6? Nonsense, obviously, but the correct answer would be 0.
Another example: Imagine a die (cube) with two 1's, one 2 and three 3's. The probability to get a 1 is obviously 1/3, the probability of 3 is 1/2. The probability of 2 (1/6) doesn't lie between.
Take a simple case: a single random number (a), which ranges from some value a_min to some other value a_max, and has some probability distribution f(a). The probability of finding a in some range a1 to a2 is the integral from a1 to a2[i] of f(a), as long as the integral from a_min to a_max is 1. For our pseudo-random number generator, a_min = 0, a_max = 1 and f(a) = 1 - namely we generate random numbers between 0 and 1 with each number being equally probable.
Once you average over two variables, things get more complex. A set of two random numbers from 0 to 1 can be represented as a square (each side of length 1) = the a-value runs along one side from 0 to 1, and the b-value runs along a side perpendicular to it from 0 to 1. The probability of a falling in a certain range (a_min to a_max) and b falling in a certain range (b_min to b_max) is the integral over the area defined by those limits (if we want to know the probability a is between 0.6 and 0.8 while b is between 0.15 and 0.37, we integrate over the rectangle defined by those 4 lines). In the case of uniform distributions, the probability is simply the area (once the total area is normalised to 1). Since we are interested in calculating the probability of getting a given calue of [i]c/[i], we have to integrate over the 'area' that gives that value of c - which is essentially a thin diagonal strip running from a=0, b=2c to a=2c, b=0 (for c < 0.5). This lets you calculate the probability distribution of c (which in this particular case looks like a triangle with its peak at c=0.5). The integration has to be done piecemeal - the limits you use for c < 0.5 are not valid for c > 0.5, so the integration is divided into two seperate functions.
Averaging over three variables (d = (a+b+c)/3), you have to find planes of constant 'd' within the cubic volume defined by a, b and c. The integration has to be done over three seperate cases (d < 1/3, 1/3 < d < 2/3, d > 2/3), and the final probability distribution of d is a set of three quadratic equations (one for each range of d listed above), giving something vaguely gaussian-shaped.
For four variables, yuo have to do integrations of 3-volume slices of a 4 dimensional hypercube, giving you a set of 4 cubic equations describing the probability distribution of your variable e=(a+b+c+d)/4. One cubic equation is valid over e=0..0.25, one for e=0.25..0.5, one for e=0.5..0.75 and one for e=0.75..1.0.
In combat calculator terms, you need to find out x, the unaveraged probability of the attacker winning one round of combat, and then integrate this set of cubic equations to determine the probability of actually winning of losing. Example: if the old-style probability of the attacker winning a single round was 0.586, the the probability of winning a single round in the new style would be found by integrating the first cubic from 0 to 0.25 plus the second from 0.25 to 0.5 plus the third from 0.5 to 0.586. The probability of losing would be the the integral of the third cubic from 0.586 to 0.75 plus the fourth cubic from 0.75 to 1.0. Once you have determine these new probabilities, you just plug them into an old combat calculator, using these new values as the probability of the attacker winning a single round. Once you've done the donkey work of finding the correct set of cubic equations, it's pretty straight forward, but getting those equations can be fairly tedious to do by hand, and rather prone to mistakes unless you are very careful.
Or you can do it the way I did - by simply simulating a few million combats fn each case. It is trivial to change the random number generator to generate an average of four numbers, and the results then follow quite happily.
Comment