by murbard2 · 10y ago · 0 comments
We're going to play a game. You draw a random number uniformly between 0 and 1. If you like it, you can keep it. If you don't, you can have a do-over and re-draw, but then you have to keep that final result.
I do the same. You do not know whether I've re-drawn and I do not know whether you've re-drawn. Decisions are made independently. We compare our numbers and the highest one wins $1.
What strategy do you use?
EDIT: The answer is not 0.5, it is not 0.7 either.
EDIT: I'll show my work, rot13'd...
Jr pna cnenzrgrevmr n fgengrtl ol n guerfubyq g: gur inyhr gung gur svefg qenj arrqf gb or yrff guna va beqre gb pubbfr gb qenj ntnva. Hfvat guerfubyq g, gur cebonovyvgl bs trggvat yrff guna g vf g^2 orpnhfr lbh unir gb qenj orybj gur guerfubyq gjvpr va n ebj. Gung chgf gur cebonovyvgl bs raqvat hc nobir gur guerfubyq ng 1-g^2.
Gur cebonovyvgl vf havsbez nobir naq orybj gur guerfubyq fb gur cebonovyvgl qvfgevohgvba bs lbhe ahzore vf:
cqs(k) = { g vs k<g ryfr g+1 }
(Gur g+1 vf sebz fbyivat gb znxr gur vagrteny sebz 0 gb 1 or 1.)Fnl lbhe bccbarag hfrf fgengrtl h naq lbh hfr fgengrtl g. Gura jr jnag gb znkvzvmr gur cebonovyvgl gung K~cqs(g) vf terngre guna L~cqs(h). Zngurzngvpn jvyy gryy hf gung vs jr nfx yvxr fb:
q[g_] := CebonovyvglQvfgevohgvba[Vs[k<g, g, g+1], {k,0,1}]
Fvzcyvsl[
Cebonovyvgl[k<l, {Qvfgevohgrq[k, q[g]],
Qvfgevohgrq[l, q[h]]}],
0<g<1 && 0<gh<1]
Gung tvirf hf gur cebonovyvgl gung g orngf h yvxr fb: c[h_,g_] := Cvrprjvfr[{
{(1+g-(1+g+g^2)*h+(1+g)*h^2)/2, h>g},
{(1+g-g^2+(g-g^2-1)*h+g*h^2)/2, h<g},
{((g^2-1)^2-g*(g^2-2)*h)/2, h==g}}]
Abj jr jnag gur g gung znkvzvmrf gung sbe n tvira h, juvpu jr trg ol gnxvat gur qrevingvir jvgu erfcrpg gb g, frggvat vg gb mreb, naq fbyivat sbe g: Fvzcyvsl[Fbyir[Q[c[g, h], g] == 0, g], 0<h<1]
Fb abj jr unir gur orfg erfcbafr gb na neovgenel fgengrtl g: oe[g_] := Cvrprjvfr[{
{(1+g+g^2)/(2+2*g), g<(Fdeg[5]-1)/2},
{(1-g+g^2)/(2*g), g>(Fdeg[5]-1)/2}}]
Vs lbh cybg gung lbh frr gung gur orfg erfcbafr vf nyjnlf orgjrra .5 naq .618. Vs lbhe bccbarag nyjnlf xrrcf gurve svefg qenj gura lbh fubhyq hfr n guerfubyq bs .5. (Fnzr vs gurl nyjnlf gnxr gur frpbaq qenj bs pbhefr.)Ohg gurl jba'g qb gung. Vs gurl hfr n guerfubyq bs 1/2 gurzfrys gura oe[1/2] == 7/12. Ohg gurl jba'g qb gung rvgure. Jung jr jnag bs pbhefr vf gur svkrq cbvag, vr, gur Anfu rdhvyvoevhz, jurer oe[g]==g. Gung, boivbhf va gur cybg, vf g = (Fdeg[5]-1)/2 nxn gur tbyqra engvb!
After some simplification, total Player A win probabilty is (-ba^2 + (b^2-b+1)a +(b^2-b+1))/2. Find a that maximizes this probability for any given b by taking the derivative and setting it to 0, which would be a = (b^2-b+1)/2b.
The game is symmetric, so at Nash equilibrium a==b. Now solve a = (a^2-a+1)/2a to get the golden ratio.
The lift over naive 0.5 threshold is very small, though, less than 1%.
Edit: thanks. This is convincing, but... given that we're looking for a fixed point of a process like... [bah, I lack words to describe a vague, non-rigorous intuition]... I expect that there is a convincing one-sentence explanation that also shows it to be the golden ratio. Am I wrong? Can anyone give a simpler explanation?
But generally...
The process is something like:
If you choose 0.5, then 0.625 beats you because that is the expected average of someone redrawing below 0.5. If you choose 0.625, then 0.617[2] beats you because that is the expected average of someone redrawing below 0.625. If you choose 0.618, then 0.6182 beats you...
Lets ignore those numbers for a moment and focus on the process: "Given a number to redraw below, redraw below the expected value of redrawing below that number".
Trying to find a fixed point for this kind of process, the golden ratio has some kind of... mythological fit? Like, I've heard so many stories like this that ended up with a formula involving the golden ratio...
I wouldn't necessarily expect the answer to be phi, but I would so not be surprised to find it to be some formula involving phi, a rational factor, and maybe pi (just because I have absolutely no intuition for which series happen to sum to rational factors of pi).
[2] I'm getting these numbers by simulation, it's too late for me here in Israel to do math
Your optimal strategy involves maximizing an objective function that depends upon your opponent's strategy. "Assume nothing" about your opponent is an incomplete problem specification, because you must assume something in order to determine which function to maximize.
For example, consider that your opponent chooses to redraw any time his number is greater than 0.5. His expected value then becomes less than 0.5, which means that if you choose to redraw any time your own number is below 0.618..., then your strategy is suboptimal.
So, we have to assume something about the opponent's strategy. Is it a uniform strategy state space? Is it a state space where both players are superrational?
Decisions and draws are independent - we can ignore the other guy and just go for the highest value. Draw the first number. If it's below 0.5, draw again, since the odds then are that the next draw will be higher.
Is there more?
def tournament(a, b, n=1000):
return sum(a() > b() for _ in xrange(n)) / n
def redraw_below(c):
x = random.random()
if x < c:
x = random.random()
return x
In [23]: tournament(lambda: redraw_below(0.5), lambda: redraw_below(0.6), n=10000000)
Out[23]: 0.4948004
In [24]: tournament(lambda: redraw_below(0.5), lambda: redraw_below(0.6), n=10000000)
Out[24]: 0.4948039
In [25]: tournament(lambda: redraw_below(0.5), lambda: redraw_below(0.6), n=10000000)
Out[25]: 0.4948802
`redraw_below(0.5)` only beats `redraw_below(0.6)` 0.4948 of the times, very consistently, over three sets of a million rounds.This is despite `0.5` giving a better average (0.624 vs. 0.620).
I'll think about why, but the result is very consistent and can't be ignored.
For example, suppose you're playing against someone who has taken the "reroll values greater than 0.5", giving them the expected value of 0.625.
If you roll the value 0.55, you expected to lose more than half the time, because their expected value is 0.625. So you should reroll anyway.
So what's the right objective? Trying to beat your opponent's median score, so that you win more than half the time?
Edit: I think you're on the right track, but I'm not sure I believe that you will lose more than half the time if you land below your opponent's expected value. I think that assumes their distribution of scores is non-skewed, which is not obvious to me.
The reason I'm wrong is that you are opposing another person's numbers - the expected dollars for a given number isn't linear. A .30 is worth way less than half as likely win you money than a .60 is.
Because of this, the shape of your distribution matters more than its "average" value.
I can't believe I forgot that AVG(F(X)) ain't necessarily F(AVG(X))
def round():
x = random.random()
if x <= 0.66666:
x = random.random()
y = random.random()
if y <= 0.5:
y = random.random()
return x >= y
sum(round() for _ in xrange(10000000))
5001450
sum(round() for _ in xrange(10000000))
5004434
sum(round() for _ in xrange(10000000))
5000238
I also ran a test of 0.6666 vs. 0.625, and... sorry to say, but 0.625 wins hands down.Now, you get. 0.500001 on your first turn. There is a 25% chance they got less than 0.5 so you win 25% of the time. Well, if they are randomly under 50% then you have a better than 75% shot of beating them with a reroll. (50% your over 0.5 and thus win and 25% you are under 0.5 and still win.)
But, they are above 0.50 then you gain a 25% chance of beating them (coin flip for over 50% and 50/50 odd or 50% of a loss) your under 50% and have even odds. Thus, you go from 25% win chance to .25 * .75 + 0.75 * 0.25 or 0.375% which is better odds for re rolling.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
for (double d = 0.25; d < .75; d += 0.01) {
double e = 0;
for (int j = 0; j < 100000; j++) {
float r = ((float) random()) / ((float) RAND_MAX);
if (r < d)
r = ((float) random()) / ((float) RAND_MAX);
e += r;
}
printf("d %lf e %lf\n", d, e / 100000);
}
}[1] probably has to do with the probability distribution having a shape more interesting than a Gaussian bell
Your comment and simulation prompted me to attempt an explanation of where danielvf's analysis is incorrect, which I've posted here https://news.ycombinator.com/item?id=12941330
For example, consider a similar game where you draw and then optionally re-draw (like in the original game) but the amount of money you win if you end up with a number p is p if p < 0.8 and p + b if p > 0.8, where b is some constant. Then you're also trying to "go for the highest value". However it is clear that in the limit of large b, your best strategy is to redraw if p < 0.8.
Though in this problem it seems the "average" final number would be 0.625, not 0.75 - since half the time you have an 0.75 expected outcome and the other half a 0.5 expected.
In other words, it isn't sufficient to shoot for the highest score possible.
I haven't solved it yet, but it's definitely some kinda recursive formula where you have to assume the other guy is also playing the optimal strategy.
I think it can be solved by searching for a pure strategy nash equilibrium
So is this one of those questions that's not possible to answer you're just trying to see how they handle the stress of the unsolvable?
If the adversary was only allowed one pick I guess I'd only re-draw if I had less than 0.5 since statistically you'd be more likely to have a greater number than a weaker one. I'm not sure what the maths are but a simple implementation gave me an average value of about 0.625 using this strategy, so definitely an improvement over a single pick.
But I have the feeling that since the adversary can chose the same strategy maybe you should be a little more aggressive and redraw if you are at 0.5? But then the adversary would do the same so I guess the solution would eventually converge to a value a little above 0.6?
That'd be my guess at least.
calc: p(a union b) = p(a) + p(b) - (p(a)*p(b)); p(>=.7)=3/10; .51 = (3/10) + (3/10) - (.3)(.3)
The idea is to find a Nash equilibrium, but the question is stated in the wrong way, since it gives no indication that you're in a position to make any assumptions about your opponent's strategy.
That said, finding the Nash equilibrium is precisely the natural thing to do if you can't make assumptions about your opponent's strategy. It's a worst case scenario analysis. You can't statistically lose out to your opponent if you pick it. This does not mean that you know your opponent strategy.
Consider the context. This is algorithmic trading. If your strategy can be gamed, it will be gamed by someone else. Picking anything but the Nash equilibrium means you can be gamed.
A good candidate will immediately gravitates towards this solution, there is no ambiguity that this is the expected answer.