Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

I have been using www.anydice.com to work out some fairly simple probabilities, but the program baffles me when trying to do anything a little more complicated.
Imagine three identical dice, sides {0, 0, 2, 2, 3, 5}
If I roll the three dice, I can work out my expected total, but what I want to know is my expected results if I allow rerolls.
What is my expected score if I reroll all zeroes?
What is my expected score if I reroll all zeroes, and then allow another reroll of all zeroes?
20gg for the hero(ine) that writes a program in AnyDice for me!!!
Thanks,
Jenks




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
You can do this looking at only one die. For one reroll,
Pr(not rolling 0) = 2/3 Pr(rolling 0 and rerolled) = 1/3
E(die  not 0) = (2+2+3+5)/4 = 3 E(die  0 and rerolled) = (2+2+3+5)/6 = 2
E(die) = E(die  not 0)Pr(not 0) + E(die  rerolled)Pr(rerolled) = (2/3)(3) + (1/3)(2) = 8/3
and E(3 dice) = 8
[Edited for clarity, several times, oops]




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
For two rerolls:
Pr(not rolling 0) = 2/3 Pr(roll 0, then not roll 0) = (1/3)(2/3) = 2/9 Pr(roll 0, reroll 0, rereroll) = (1/3)(1/3) = 1/9
E(die  not 0) = 3 (as before) E(die  0, 0, rereroll) = 2
so E(die) = (2/3 + 2/9)(3) + (1/9)(2) = 8/3 + 2/9 = 26/9
and E(three dice) = 26/3




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
It seems to me that allowing n rerolls of zeroes results in an expected value per die of 3 – (1/3)^(n – 1); i.e., with
0, 1, 2, 3, ... rerolls the expected value per die is
2, 8/3, 26/9, 80/27, ....


Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
having forgotten all my statistics from school, please humour me a little...
I take it that Pr(something) = probilility of rolling it and E(something) is the expected average value?
Thanks!




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Pr(x) = probability of x and E(x) = expected value of x, yes.


Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
robigo wrote: You can do this looking at only one die. For one reroll,
Pr(not rolling 0) = 2/3 Pr(rolling 0 and rerolled) = 1/3
E(die  not 0) = (2+2+3+5)/4 = 3 E(die  0 and rerolled) = (2+2+3+5)/6 = 2
E(die) = E(die  not 0)Pr(not 0) + E(die  rerolled)Pr(rerolled) = (2/3)(3) + (1/3)(2) = 8/3
and E(3 dice) = 8
[Edited for clarity, several times, sigh]
The bit in bold is the only bit that confuses me (so far)




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Jenkachu wrote: robigo wrote: You can do this looking at only one die. For one reroll,
Pr(not rolling 0) = 2/3 Pr(rolling 0 and rerolled) = 1/3
E(die  not 0) = (2+2+3+5)/4 = 3 E(die  0 and rerolled) = (2+2+3+5)/6 = 2
E(die) = E(die  not 0)Pr(not 0) + E(die  rerolled)Pr(rerolled) = (2/3)(3) + (1/3)(2) = 8/3
and E(3 dice) = 8
[Edited for clarity, several times, sigh] The bit in bold is the only bit that confuses me (so far)
Robigo is dividing by 6 because there are six equally possible outcomes for rerolling the die  0, 0, 2, 2, 3, 5
Note that if you allow limitless rerolls, you are simply rolling a die with four sides: 2, 2, 3, 5


B C Z
United States Reston Virginia

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
It's a bit confusing because expected value of a die doesn't necessarily equate to a possible die face.
Take this die: (1, 1, 1, 1, 1, 7)
The expected value of rolling this dies is "2", but I cannot roll a 2!
(1+1+1+1+1+7 = 12/6 = 2)




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Jenkachu wrote: robigo wrote: You can do this looking at only one die. For one reroll,
Pr(not rolling 0) = 2/3 Pr(rolling 0 and rerolled) = 1/3
E(die  not 0) = (2+2+3+5)/4 = 3 E(die  0 and rerolled) = (2+2+3+5)/6 = 2
E(die) = E(die  not 0)Pr(not 0) + E(die  rerolled)Pr(rerolled) = (2/3)(3) + (1/3)(2) = 8/3
and E(3 dice) = 8
[Edited for clarity, several times, oops] The bit in bold is the only bit that confuses me (so far) I assume that if you roll 0 and reroll, you have to take whatever shows up, even of 0. Then the expected value is the sum of
Pr(face)*Value(face)
over all six faces. The probability of each face is 1/6 (assuming a fair die, of course) and the values are 0, 0, 2, 2, 3, 5, so
E(die  reroll) = (1/6)(0) + (1/6)(0) + (1/6)(2) + (1/6)(2)+ (1/6)(3)+ (1/6)(5),
which can be condensed to (2 + 2 + 3 + 5)/6. Sorry about all the math shortcuts.


Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Of course... Silly me. Thanks, both of you.
The 20gg bounty still stands for anyone that can put this into anydice for me. I am interested in the chances of achieving different totals as I fiddle with the numbers on the die.


Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
byronczimmer wrote: It's a bit confusing because expected value of a die doesn't necessarily equate to a possible die face.
Take this die: (1, 1, 1, 1, 1, 7)
The expected value of rolling this dies is "2", but I cannot roll a 2!
(1+1+1+1+1+7 = 12/6 = 2)
It's 'stuff' I am rolling for, so I want to know how much 'stuff' I can expect the player to have, and also I'm interested in the deviation from the mean; I am not sure yet whether I want this to be high or low...




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
byronczimmer wrote: It's a bit confusing because expected value of a die doesn't necessarily equate to a possible die face.
Take this die: (1, 1, 1, 1, 1, 7)
The expected value of rolling this dies is "2", but I cannot roll a 2!
(1+1+1+1+1+7 = 12/6 = 2)
That's true for every one of the standard Platonic dice as well, as the expected values are all halfintegers (true for any die with numbers 1 through n, where n is even).




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Jenkachu wrote: Of course... Silly me. Thanks, both of you.
The 20gg bounty still stands for anyone that can put this into anydice for me. I am interested in the chances of achieving different totals as I fiddle with the numbers on the die.
Thank you! Sorry, I can't help you with anydice. Now, if you were using the R statistical programming language, then I could whip something up in about three lines.


Jessey
Canada
I also purchased this and do not know what to do with it!
I purchased this and do not know what to do with it!

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
Been futzing around with AnyDice this whole time, I think this does the trick. I am also 99% sure that there is a shorter way to achieve the same result:
Roll 3 dice and reroll first 0's function: roller A:n{ if A = 0 {result: d{0,0,2,2,3,5}} result: A}
function: multiroll { result: [roller d{0,0,2,2,3,5}] + [roller d{0,0,2,2,3,5}] + [roller d{0,0,2,2,3,5}] }
output [multiroll]
It's very primitive. The first function accepts the dice roll of the correct type, then rerolls if it if comes up 0. The second function calls the first function 3 times. Then the output command calls the second function.
Using recursion I can probably make this a single function but I'm still trying to understand AnyDice syntax.




Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
It's a bit crude, but http://anydice.com/program/119e does it.
function: newdie { result: d{0, 0, 2, 2, 3, 5} }
function: rerolldie ROLL:n REROLLS:n { if ((ROLL=0)&(REROLLS>0)) { result: [rerolldie [newdie] REROLLS1] } else { result:ROLL } }
output 3d[rerolldie [newdie] 1]
Edit: I should explain;
Newdie just defines your die, both so you only have to change it in one place and because of the way anydice passes values.
Rerolldie takes the roll of a die and the number of rerolls which are allowed. On a zero, if there are any rerolls left, it calls itself with one less reroll.
The last line just calls rerolldie, using newdie (as defined above), with one reroll allowed. Change the '1' to get a different number of rerolls.
Edit again: Why can I never get a post right the first time? The code I posted gives you 1 of your dice, not 3. Corrected and link changed. The '3d' part on the last line decides how many dice you are rolling.
When Anydice gives you your results, they are titled 'output 1' (unless you change this). Beside this is the expectation value, which is what you wanted more than the histogram, I think.


Jenks
Germany Eckernfoerde SchleswigHolstein
Lest we Forget

Re: Need help with some dice  I think Anydice should be able to calculate what I want, but I can't get the bugger to work...
old_gamer wrote: It's a bit crude, but http://anydice.com/program/119e does it. function: newdie { result: d{0, 0, 2, 2, 3, 5} }
function: rerolldie ROLL:n REROLLS:n { if ((ROLL=0)&(REROLLS>0)) { result: [rerolldie [newdie] REROLLS1] } else { result:ROLL } }
output 3d[rerolldie [newdie] 1]
Edit: I should explain; Newdie just defines your die, both so you only have to change it in one place and because of the way anydice passes values. Rerolldie takes the roll of a die and the number of rerolls which are allowed. On a zero, if there are any rerolls left, it calls itself with one less reroll. The last line just calls rerolldie, using newdie (as defined above), with one reroll allowed. Change the '1' to get a different number of rerolls. Edit again: Why can I never get a post right the first time? The code I posted gives you 1 of your dice, not 3. Corrected and link changed. The '3d' part on the last line decides how many dice you are rolling. When Anydice gives you your results, they are titled 'output 1' (unless you change this). Beside this is the expectation value, which is what you wanted more than the histogram, I think.
Perfect. Thank you very much.
Jessey  Thanks also to you!


Jessey
Canada
I also purchased this and do not know what to do with it!
I purchased this and do not know what to do with it!

Ahh, but thank you! I wouldn't have known about this neat thing for working out dice probabilities were it not for the challenge you set before us.




Jenkachu wrote: Perfect. Thank you very much. You're welcome, and thank you for a fun question. (And the GG!)



