Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > Other Topics > Science, Math, and Philosophy
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2005, 07:47 PM
ChromePony ChromePony is offline
Member
 
Join Date: Jul 2004
Posts: 71
Default Dice Game

This could probably go in the probability forum, but theres way too much philosophy around here and not enough math so lets give it a shot.

A friend of mine posed this to me after he was asked it on a job interview, heres the game, its pretty simple.

You roll a fair 6 sided die and are given an amount of money equal to the number you roll, 1=$1 2=$2...etc. The caveat is that if you wish to reroll you may, but would then be stuck with whatever you get the second time.

The question is, how much would you be willing to pay to play this game? read: what is the EV
(this is what he was asked to figure out on the spot)

A slightly less trival extension, what if you get up to 6 rolls, meaning you can choose to reroll 5 times before you are stuck with the 6th.
(he was given this as 'homework')

Finally and most interestingly, how about generalizing it for n rolls...just for kicks
Reply With Quote
  #2  
Old 08-23-2005, 07:55 PM
durron597 durron597 is offline
Junior Member
 
Join Date: Apr 2004
Posts: 6
Default Re: Dice Game

Clearly if you get a 1-3 you should reroll and if you get a 4-6 you should keep. If the game was played with only one roll the $EV is 3.5. Thus the EV of this game is:

1/6 * (4) + 1/6 * (5) + 1/6 * (6) + 1/2 * (3.5) = $4.25
Reply With Quote
  #3  
Old 08-23-2005, 08:13 PM
ChromePony ChromePony is offline
Member
 
Join Date: Jul 2004
Posts: 71
Default Re: Dice Game

[ QUOTE ]
Clearly if you get a 1-3 you should reroll and if you get a 4-6 you should keep. If the game was played with only one roll the $EV is 3.5. Thus the EV of this game is:

1/6 * (4) + 1/6 * (5) + 1/6 * (6) + 1/2 * (3.5) = $4.25


[/ QUOTE ]

Very nice, but thats the easy part. I'm guessing most people who hang out around here could get that pretty quick, I'm more interested in the n-generalization since I have an answer but its not all that elegant, wondering if someone can come up with a better approach.
Reply With Quote
  #4  
Old 08-23-2005, 08:25 PM
durron597 durron597 is offline
Junior Member
 
Join Date: Apr 2004
Posts: 6
Default Re: Dice Game

Well, I thought about it for awhile. The answer is definitely 5 - 3/(2^n), though I'm having trouble proving it. I'll think about it some more.
Reply With Quote
  #5  
Old 08-23-2005, 08:33 PM
Moozh Moozh is offline
Member
 
Join Date: Jan 2004
Posts: 40
Default Re: Dice Game

If you had infinite rolls, wouldn't you expect to end up with a 6?
Reply With Quote
  #6  
Old 08-23-2005, 08:34 PM
durron597 durron597 is offline
Junior Member
 
Join Date: Apr 2004
Posts: 6
Default Re: Dice Game

[ QUOTE ]
If you had infinite rolls, wouldn't you expect to end up with a 6?

[/ QUOTE ]

But you don't have infinite rolls. You have a certain number of rolls and then you stop.

Hm. Maybe my optimal strategy is not, in fact, optimal. If you have 20 rolls left and you roll a 5, my strategy says stop. That is clearly wrong, but it's where my answer comes from.
Reply With Quote
  #7  
Old 08-23-2005, 09:19 PM
Jordan Olsommer Jordan Olsommer is offline
Senior Member
 
Join Date: May 2005
Posts: 792
Default Re: Dice Game

Can the general solution even be expressed mathematically? It seems like it requires a conditional ("if current roll is < EV of replacing, replace. Lather, rinse, repeat."). It could be easily done as a recursive function, though.

FWIW, According to my calculations, for n=20 rolls you should replace anything lower than a six for the first 15 rolls, then take a 5 or 6 for rolls 16-18, then 4, 5, or 6 on roll 19, and of course whatever you can get on roll 20.
Reply With Quote
  #8  
Old 08-23-2005, 10:34 PM
Jordan Olsommer Jordan Olsommer is offline
Senior Member
 
Join Date: May 2005
Posts: 792
Default Re: Dice Game

I still don't know how to collapse it down to a simple mathematical statement*, but this will do it if you have a python interpreter handy (n = max number of rolls you're allowed)

<font class="small">Code:</font><hr /><pre>
import math

def EV(n):
if n==1:
return 3.5
else:
ev_replace = EV(n-1)
threshold = math.floor(ev_replace)
ev_keep = (21 - (((threshold)*(threshold+1))/2))/6
ev = (threshold / 6)*(ev_replace) + ev_keep
return ev
</pre><hr />

Here are the results for the first 20 values of n:

3.5
4.25
4.66666666667
4.94444444444
5.12962962963
5.27469135802
5.39557613169
5.49631344307
5.58026120256
5.6502176688
5.708514724
5.75709560333
5.79757966944
5.8313163912
5.859430326
5.882858605
5.90238217084
5.91865180903
5.93220984086

and here's what your EV is if you are given 100 rolls

5.99999997385

*edit: Duh. It was staring me right in the face, but it's really ugly, and I don't like being stared at by things that are ugly, so that's probably why I didn't include it before. It's just a recursive function with a couple floors thrown in, same as in the code snippet

F(1) = 3.5
F(n) = ( floor( F(n-1) ) * F(n-1) ) / 6 + ( 21 - ( floor( F(n-1) )* (floor ( F(n-1) + 1)) / 2 ) ) / 6

I'm quite sure I have the wrong number of parens in there, but oh well.
Reply With Quote
  #9  
Old 08-23-2005, 11:16 PM
Jordan Olsommer Jordan Olsommer is offline
Senior Member
 
Join Date: May 2005
Posts: 792
Default Re: Dice Game

And since the max edit time is up on my last post, and because the recursive function I included at the end looks like a keyboard barf, I made it look perty:

Reply With Quote
  #10  
Old 08-23-2005, 11:29 PM
BruceZ BruceZ is offline
Senior Member
 
Join Date: Sep 2002
Posts: 1,636
Default Re: Dice Game

[ QUOTE ]
You roll a fair 6 sided die and are given an amount of money equal to the number you roll, 1=$1 2=$2...etc. The caveat is that if you wish to reroll you may, but would then be stuck with whatever you get the second time.

The question is, how much would you be willing to pay to play this game? read: what is the EV

[/ QUOTE ]

The average for 1 die is 3.5, so keep 4,5,6 (avg = 5) and roll 1,2,3 again. The EV is

(1/2)*5 + (1/2)*3.5 = $4.25 for 2 dice.


[ QUOTE ]
A slightly less trival extension, what if you get up to 6 rolls, meaning you can choose to reroll 5 times before you are stuck with the 6th.

[/ QUOTE ]


EV(n) = EV for n rolls.
Work backward from 2 remaining rolls.
Since EV(2) = 4.25, keep 5+ (avg = 5.5) and roll 1,2,3,4:

2 rolls left, keep 5+, EV(3) = (1/3)*5.5 + (2/3)*4.25 = 4 + 2/3

3 rolls left, keep 5+, EV(4) = (1/3)*5.5 + (2/3)*(4 2/3) = 4 + 17/18

4 rolls left, keep 5+, EV(5) = (1/3)*5.5 + (2/3)*(4 + 17/18) = 5 + 7/54

5 rolls left, keep 6, EV(6) = (1/6)*6 + (5/6)*(5 + 7/54) = 5 + 84/325 =~ $5.27 for 6 dice.


[ QUOTE ]
Finally and most interestingly, how about generalizing it for n rolls...just for kicks

[/ QUOTE ]

For n &gt; 6, EV(n) = (1/6)*6 + (5/6)*EV(n-1)

recursion: EV(n) = 1 + (5/6)*EV(n-1)

EV(6) = 5.27
EV(7) = 1 + (5/6)*5.27
EV(8) = 1 + 5/6 + (5/6)^2 * 5.27
EV(9) = 1 + 5/6 + (5/6)^2 + (5/6)^3 * 5.27
...
EV(n) = sum [i = 0 to n-7](5/6)^i + (5/6)^(n-6) * 5.27

from finite sum geometric series:

EV(n) = [1 - (5/6)^(n-6)]/(1 - 5/6) + (5/6)^(n-6) * 5.27

EV(n) = 6 - 6*(5/6)^(n-6) + 5.27 * (5/6)^(n-6)

EV(n) = 6 - 0.73*(5/6)^(n-6), for n &gt; 6 dice.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.