Question about probability in game
So I have game I'm designing where you get an item 1 in x times. But because of bad luck you may not get the item in x times and if you don't the next roll I automatically give it to you. This will throw off the probability as I still want it to be 1 in x but it will be slightly higher as I give it to you automatically if you don't get it. How would I calculate the probability to get a proper X?
For example lets say you get a gold coin 1 in 6 times. But after 6 rolls you haven't gotten a coin. So the next roll I automatically give you a coin. But I still want the probability to be 1 in 6. So in order for it to be 1 in 6 with "auto give" roll I would have to adjust the initial probability to be like 1 in 6.5.
Posted Jun 13, 2017, 1:54 PM UTC
What you are describing is a process in which there could be an infinite number of rolls until you get a prize, but you want to enforce a maximum of
x+1. If you keep a variableywhich counts the number of rolls, then you'd just need to put in a condition: IF( y>x ) THEN( give prize and reset y to 0 ).Now, from your description, it sounds like you want to consider each roll as an independent trial, but you've noted that doing so, it's possible that in
xtrials the player may not get the prize. So, you want to add a seventh roll that will guarantee success, and have a probability distribution. As other have at this point noted, this is not possible in our framework. However, if you change perspective slightly, the problem becomes easy.Instead of looking at the rolls individually, consider generating the value
ysuch that "the prize is obtained on roll y". This is just sampling from a uniform distributionP(G=y) = 1/xfory=1,...,x. Just as I mentioned in the first paragraph, you'd need a countery, but in this case, you'd be sampling a value, sayz=3, and then the player gets no prize untily=z.If you really wanted to use the concept of getting a guarantee win on the
x+1roll, there are a variety of ways in which you could assign the probabilities, but in the end you would still need to use the approach I just described: sample the valuezwhich defines the roll on which the player will get the prize. One way you could do this and incorporate the idea of independent rolls would be the following:Calculate the probability of No Prize on the first
xrolls, which is(1 - 1/x)^x. This is the probability of getting the prize on thex+1roll (since it is a guarantee). Then subtract this from 1 to get the probability that the prize is somewhere among the firstxrolls, and distribute evenly (divide byx). So the probability of a Prize on rolls 1,...,6 would beP(G=y) = [ 1 - (1 - 1/x)^x ] / xfory=1,...,x. In the example ofx=6, this yields the following probabilities:Then, this is just a multinomial distribution, and you'd be sampling the roll at which the player gets the prize (the value
zI mentioned earlier), but now there are unequal probabilities.The sum of all probability values for all discrete values in an actual pmf is 1. What you have written is not a pmf.
Care to explain?
Edit: Nevermind, I assume you were talking about the initial "PMF", and not the table. Edited the original.
Note that in this case, the probability of success changes with each successive failed roll.
if you want the probability to stay the same between the rolls up until the guaranteed roll, you'll have to do the math a little differently.