Results 1 to 10 of 10

Math Help - Probability distribution for fun!

  1. #1
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Probability distribution for fun!

    I notice most questions here are for homework or such, but i graduated long ago and just like to have some fun sometimes, so I don't mean to take away time from helping any of the students out there but would appreciate some guidance if anyone can offer any.

    I sometimes like making complicated excel charts to emulate certain video game mechanics by figuring out their hidden equations, coming up with various other statistics, probabilities, etc. See, like I said, FUN right? ...Yeah my wife doesn't think so either but I'm weird I guess.

    I'm currently emulating the combat of a turn based strategy game, and have everything completed except for the probability distribution over the different possible damage values when 1 unit stack attacks another. It's sort of like adding multiple dice rolls except the rolls are put through a function before being added which is throwing me off.

    The situation is such.
    When 1 stack of units attacks another, a random number is chosen from their damage range, lets use an example of 32-34 base damage. The number is put through a function to factor in other things like stats/gear/etc which isn't important here but gives some value that is usually not an integer. To give an accurate picture in this example the function returns these values bases on what number was chosen.
    F(32) = 37.54666...7
    F(33) = 38.72
    F(34) = 39.89333...

    This happens for each unit in the stack and is added together before it is rounded to a final integer.

    So if there are 11 units in the stack, then you would have 11 random choices from the set F(32), F(33), F(34) that are added together and rounded to the nearest integer. The min value would be Round(F(32)*11) and max is obviously Round(F(34)*11)
    When rounded the range of damage is 413 - 439

    What I want to do list all of the possible damages 413 - 439 and give the probability that the sum of the 11 random choices will round to that number.

    I've tried to modify one of the dice algorithms I found here Dice - Wikipedia, the free encyclopedia but since the numbers are put through the function and are not integers, not consecutive, and not starting at 1, I have been unable to figure out what to do.

    For an even more advanced bonus idea I'd, like to be able to set ranges and find the probability that the result falls in that range. This is because some units damage range and stack size might mean a total damage result anywhere from 500-2000, so for these I might give the probability of the damage falling between 500-599, 600-699, etc.

    Any ideas or help is welcome.

    Thanks for reading,
    Shawn
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,619
    Thanks
    592

    Re: Probability distribution for fun!

    Hey gyan1010.

    One suggestion for you is to think about the process rather than the empirical distribution: you can analyze whether the empirical results mimic the properties of a particular process, but it's a lot harder to do the reverse.

    You also might want to look at the probability models for AI chess (the one that the IBM supercomputer uses) and see how it not only evaluates probabililty, but uses them to make the best move given the current board state and the history of play: you can modify this for your turn based strategy game.

    Have you looked into such things?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    No I haven't.

    I'm not however trying to create an AI for moving. In this game the board can vary and there are just to many variables and non damage abilities and such that change things for me to attempt that.

    It's more of a curiosity factor, and I thought it would be something cool to add in my spreadsheet.

    I started this because there was a challenge from one of the devs to see who could determine how many of unit X would it take to kill n number of unit Y. There was some dispute over the answer because it was not made clear if X had to kill all of Y units 100% of the time. It so happened that the answer given meant that on a near minimum hit only n-1 units would die. I started thinking, although it was a small chance I wonder what percentage of the time only n-1 units die. Then I thought it would be cool to know exactly what chance you have of killing a certain number of units. I know several times I see a stack with lets say 20 units, and before an attack I can see that I would kill lets say 19-20 units. It would be nice to know if the odds are on my side that the whole stack will die or if I should just attack that stack later in the round with a stronger unit.

    Anyway, I started fiddling with some formulas, and here we are.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,619
    Thanks
    592

    Re: Probability distribution for fun!

    You can calculate the distribution of a function of a random variable.

    If you outline the random variables and the transformations applied along with what you are trying to calculate (sum of different random variables etc) then I can outline how you get a distribution for this.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    Not sure anymore what a proper outline would look like.

    Although the function contains many variables initially, once both attacker and defender are chosen, all but the damage roll becomes constant. The damage roll has a liner effect on the function.

    So if f(x) is the damage function and k is constant and x is a random integer within the damage range, then...
    f(x) = kx

    n = number of units in the stack
    I need the sum from 1 to n of f(x) but with a new random x each iteration.

    Anyway, its late here and I'm done for the night but thanks for taking an interest.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,619
    Thanks
    592

    Re: Probability distribution for fun!

    Hey gyan1010.

    If all the x's in each iteration are independent, this is an easy problem that has been worked out. If each new variable depends on what happened in the last iteration, then again there are ways to do this.

    If you can outline how x changes with iteration mathematically we'll take it from there.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    x is independent each time.

    Example:
    If a 5 stack of Unit A attacks Unit B
    And Unit A has a damage range of 10-14

    Total Damage = \sum_{1}^{n}f(x) = \sum_{1}^{5}f(Random(10,14))
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    Any luck figuring out how to do this?

    Here the way I'd sum up the problem again

    Integer values
    n = number of independent rolls
    a = min value of roll
    b = max value of roll
    x = Random(a,b) ;New value for each roll

    Floating point value
    f(x) = linear function of x
    Y = Round(\sum_{1}^{n}f(x))

    Logically...
    Ymin = Round(\sum_{1}^{n}f(a))
    and...
    Ymax = Round(\sum_{1}^{n}f(b))

    For rounding purposes I figure...
    Y = \left\{\begin{matrix}\left \lfloor \sum_{1}^{n}f(x) \right \rfloor &;if \sum_{1}^{n}f(x) - \left \lfloor \sum_{1}^{n}f(x) \right \rfloor < 0.5 \\ \left \lceil \sum_{1}^{n}f(x) \right \rceil  &;if \sum_{1}^{n}f(x) - \left \lfloor \sum_{1}^{n}f(x) \right \rfloor >= 0.5\end{matrix}\right

    I am trying to find the probability distribution for
    Ymin
    Ymin+1
    Ymin+2
    Ymin+3
    ...
    ...
    ...
    Ymax
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    Upon doing some plot tests I've discovered I may be able to do this a totally different way but I'm having trouble with the exact process.

    Since f(x) is linear, we can just assume there is some multiplier "k" that modifies it.
    Also assume the previous posts letter assignments for n, a, b, and x
    Let R be the range from a to b including a & b
    R = b-a+1

    I knew that the minimum value of the sum is always Round(n*a*k), and I can noticed I can figure out all of the possible sums by adding k to the pre-rounded value until I reach n*b*k

    Anyway, once you have the possible sums in order I found a pattern in how often they occur in a complete sums table. The pattern seems based somewhat on pascal's triangle and also follows the bell curve. For reference here is some of pascals triangle, but rotated a bit from how you might have seen it back in school.

    1 1 1 1 1 1 1 1
    1 2 3 4 5 6 7
    1 3 6 10 15 21
    1 4 10 20 35
    1 5 15 35
    1 6 21
    1 7
    1

    We can tell mathematically that the number of total combinations is R^n.
    So to get the probability of how often each possible sum occurs we can easily do that if we know how many times it occurs in the total table and divide by R^n
    I found through testing that the 1st R possible sums, occur a number of times equal to the 1st R terms of the nth row of pascals triangle when written how I have it. Since it is a bell curve the last R values are the same in reverse as well

    Example time:
    If R = b-a+1 = 4
    and n = 3

    Possible sums # of times sum occurs Pascal's Triangle reference
    n*a*k+(k*0) 1 row n col 1
    n*a*k+(k*1) 3 row n col 2
    n*a*k+(k*2) 6 row n col 3
    n*a*k+(k*3) 10 row n col 4
    n*a*k+(k*4) 12 ? unsure how the middle values relate
    n*a*k+(k*5) 12 ? unsure how the middle values relate
    n*a*k+(k*6) 10 row n col 4
    n*a*k+(k*7) 6 row n col 3
    n*a*k+(k*8) 3 row n col 2
    n*b*k 1 row n col 1

    If I can figure out how those middle values in the set can be calculated then I can find the answer I am looking for.

    Some more example sets with the bold numbers being the non-pascal's triangle values
    n=3; R=7 n=4; R=4 n=5; R=3 n=5; R=2 n=2; R=8
    1
    3
    6
    10
    15
    21
    28
    33
    36
    37
    36
    33

    28
    21
    15
    10
    6
    3
    1
    1
    4
    10
    20
    31
    40
    44
    40
    31

    20
    10
    4
    1
    1
    5
    15
    30
    45
    51
    45
    30

    15
    5
    1
    1
    5
    10
    10

    5
    1
    1
    2
    3
    4
    5
    6
    7
    8
    7
    6
    5
    4
    3
    2
    1
    Last edited by gyan1010; October 10th 2012 at 06:47 AM.
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Junior Member
    Joined
    Sep 2008
    Posts
    28

    Re: Probability distribution for fun!

    Wait I did it!

    Its the same curve as with dice. The values are different but probabilities are the same. Since I already found the values a different way, I'm just going to calculate the probability as if the range was an S-sided dice and the quantity n and use the wiki page describing n tosses of s-sided dice.

    Seems to work nice but to bad excel cant handle larger than double precision numbers. It totally breaks on 1 case where the damage range is 4 and stack size can reach upwards of 600, which would require a 4^600 calculation.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Probability distribution
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: December 4th 2011, 08:32 AM
  2. Replies: 1
    Last Post: February 18th 2010, 01:54 AM
  3. Probability Distribution
    Posted in the Statistics Forum
    Replies: 0
    Last Post: June 19th 2009, 06:45 PM
  4. Probability distribution
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: April 21st 2009, 05:10 PM
  5. probability distribution ...
    Posted in the Statistics Forum
    Replies: 1
    Last Post: May 25th 2007, 09:25 AM

Search Tags


/mathhelpforum @mathhelpforum