Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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 re-rolls.

What is my expected score if I re-roll all zeroes?

What is my expected score if I re-roll all zeroes, and then allow another re-roll of all zeroes?

20gg for the hero(ine) that writes a program in AnyDice for me!!!

Thanks,

Jenks
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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 re-roll,

Pr(not rolling 0) = 2/3
Pr(rolling 0 and re-rolled) = 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 | re-rolled)Pr(re-rolled)
= (2/3)(3) + (1/3)(2) = 8/3

and E(3 dice) = 8

[Edited for clarity, several times, oops]
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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 re-rolls:

Pr(not rolling 0) = 2/3
Pr(roll 0, then not roll 0) = (1/3)(2/3) = 2/9
Pr(roll 0, re-roll 0, re-re-roll) = (1/3)(1/3) = 1/9

E(die | not 0) = 3 (as before)
E(die | 0, 0, re-re-roll) = 2

so E(die) = (2/3 + 2/9)(3) + (1/9)(2) = 8/3 + 2/9 = 26/9

and E(three dice) = 26/3
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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 re-rolls of zeroes results in an expected value per die of 3 – (1/3)^(n – 1); i.e., with

0, 1, 2, 3, ... re-rolls the expected value per die is

2, 8/3, 26/9, 80/27, ....
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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!
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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 re-roll,

Pr(not rolling 0) = 2/3
Pr(rolling 0 and re-rolled) = 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 | re-rolled)Pr(re-rolled)
= (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)
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Old Gamer
United Kingdom
flag msg tools
badge
Avatar
mbmbmbmbmb
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 re-roll,

Pr(not rolling 0) = 2/3
Pr(rolling 0 and re-rolled) = 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 | re-rolled)Pr(re-rolled)
= (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
2 
 Thumb up
1.00
 tip
 Hide
  • [+] Dice rolls
B C Z
United States
Reston
Virginia
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
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)
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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 re-roll,

Pr(not rolling 0) = 2/3
Pr(rolling 0 and re-rolled) = 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 | re-rolled)Pr(re-rolled)
= (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 re-roll, 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 | re-roll) = (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.



2 
 Thumb up
10.00
 tip
 Hide
  • [+] Dice rolls
Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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...
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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 half-integers (true for any die with numbers 1 through n, where n is even).
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
いい竹やぶだ!

South Euclid
Ohio
msg tools
Avatar
mbmbmb
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.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jessey
Canada
flag msg tools
designer
I also purchased this and do not know what to do with it!
badge
I purchased this and do not know what to do with it!
Avatar
mbmbmbmbmb
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.

2 
 Thumb up
10.00
 tip
 Hide
  • [+] Dice rolls
Old Gamer
United Kingdom
flag msg tools
badge
Avatar
mbmbmbmbmb
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] REROLLS-1]
}
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.
5 
 Thumb up
20.00
 tip
 Hide
  • [+] Dice rolls
Jenks
Germany
Eckernfoerde
Schleswig-Holstein
flag msg tools
badge
Lest we Forget
Avatar
mbmbmbmbmb
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] REROLLS-1]
}
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!
1 
 Thumb up
5.00
 tip
 Hide
  • [+] Dice rolls
Jessey
Canada
flag msg tools
designer
I also purchased this and do not know what to do with it!
badge
I purchased this and do not know what to do with it!
Avatar
mbmbmbmbmb
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.

2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Old Gamer
United Kingdom
flag msg tools
badge
Avatar
mbmbmbmbmb
Jenkachu wrote:
Perfect. Thank you very much.

You're welcome, and thank you for a fun question. (And the GG!)
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.