Robert Israel

6522 Reputation

21 Badges

18 years, 187 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are replies submitted by Robert Israel

Here's another version.  This time the turn number doesn't matter: which game you play is decided randomly. 

You have three coins, Coin 1 which wins with probability 4/5, Coin 2 which always loses, and Coin 3 (used only in Game C to decide whether to play a turn of A or B) which is fair: probability 1/2 for heads and 1/2 for tails.

Game A: if fortune divisible by 3, flip Coin 2, otherwise flip Coin 1.

Game B: if fortune congruent to 1 mod 3, flip Coin 2, otherwise flip Coin 1.

Game C: Flip Coin 3.  If heads play a turn of Game A, if tails play a turn of Game B.  .

In Game A, the three states (fortune == 0 mod 3, 1 mod 3 and 2 mod 3) have long-run probabilities  21/51, 5/51 and 25/51 respectively. 
Your expected gain per turn is (-1)*21/51 + 3/5*5/51 + 3/5*25/51 = -1/17.  Similarly in Game B.

In Game C, you always flip Coin 1 if your fortune == 2 mod 3, otherwise effectively you're flipping a coin with winning probability 2/5.  The long-run
probabilities of the three states are then 13/55, 19/55 and 23/55, and the expected net gain per turn is (-1/10)*13/55 + (-1/10)*19/55 + 3/5*23/55 = 53/275.

 

> S0 := [[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0]]:
  n:= 4:
  X:= Array(0..n-1,0..n-1,S0);

X := Array(0 .. 3,0 .. 3,{(1, 1) = 1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1},datatype = anything,storage = rectangular,order = Fortran_order)

> S0 := [[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0]]:
  n:= 4:
  X:= Array(0..n-1,0..n-1,S0);

X := Array(0 .. 3,0 .. 3,{(1, 1) = 1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1},datatype = anything,storage = rectangular,order = Fortran_order)

As in your original post, use phaseportrait if you want solution curves too.

So for example:

> with(plots): with(DEtools):
  hyperb:= implicitplot( y^2 - x^2 - 1, x = -4 .. 4, y = -3 .. 3, colour=gold):
  phasep:= phaseportrait([(D(x))(t) = -.1+x(t)^2-x(t)*y(t), (D(y))(t) = y(t)^2-x(t)^2-1], [x(t), y(t)], t = -10 .. 10, 
   [ [x(-2) = -2, y(-2) = -1], [x(0) = 1, y(0) = 0], [x(0) = -0.04, y(0) = 1],[x(0)=-.14,y(0)=1.012]],
   x=-4..4,y=-3..3, stepsize=0.01, linecolour=[red,green,blue,blue]):
  display([hyperb, phasep], 

What other hyperbola were you expecting?

As in your original post, use phaseportrait if you want solution curves too.

So for example:

> with(plots): with(DEtools):
  hyperb:= implicitplot( y^2 - x^2 - 1, x = -4 .. 4, y = -3 .. 3, colour=gold):
  phasep:= phaseportrait([(D(x))(t) = -.1+x(t)^2-x(t)*y(t), (D(y))(t) = y(t)^2-x(t)^2-1], [x(t), y(t)], t = -10 .. 10, 
   [ [x(-2) = -2, y(-2) = -1], [x(0) = 1, y(0) = 0], [x(0) = -0.04, y(0) = 1],[x(0)=-.14,y(0)=1.012]],
   x=-4..4,y=-3..3, stepsize=0.01, linecolour=[red,green,blue,blue]):
  display([hyperb, phasep], 

What other hyperbola were you expecting?

That's a rather funky Maple leaf.  Here's a more standard flag.  It requires Standard GUI (because Classic doesn't fill polygons properly).

> with(plots):with(plottools):
  G1:= (p1,p2) -> arccos(.3/sqrt((p1[1]-p2[1])^2 + (p1[2]-p2[2])^2)) + arctan(p2[2]-p1[2],p2[1]-p1[1]):
  G2:= (p1,p2) -> -arccos(.3/sqrt((p1[1]-p2[1])^2 + (p1[2]-p2[2])^2)) + arctan(p2[2]-p1[2],p2[1]-p1[1]):
  C:=[31.5,2],[32.5,2], 
    op(op(arc([32.5,8], .3,  G2([32.5,8],[32.5,2])+2*Pi.. G1([32.5,8],[39,7.5])))),
    [39,7.5],
    op(op(arc([38.3,9.5],.3, G2([38.3,9.5],[39,7.5])+2*Pi .. G1([38.3,9.5],[44.6,15])))),
    [44.6,15],
    op(op(arc([43.3,16.1],.3, G2([43.3,16.1],[44.6,15])+2*Pi .. G1([43.3,16.1],[44.1,20.1])))),
    [44.1,20.1],
    op(op(arc([40.5,20],.3, G2([40.5,20],[44.1,20.1])+2*Pi .. G1([40.5,20],[39.5,21.5])))),
    [39.5,21.5],
    op(op(arc([35.8,18.3],.3,G2([35.8,18.3],[39.5,21.5])+2*Pi .. G1([35.8,18.3],[37,25.5])))),
    [37,25.5],
    op(op(arc([34.3,24.9],.3,G2([34.3,24.9],[37,25.5])+2*Pi .. G1([34.3,24.9],[32,29])))),
    [32,29]:
  C:= C,op(ListTools[Reverse](map(t -> [64-t[1],t[2]], [C]))):
  display([POLYGONS([C],COLOUR(RGB,1,0,0)),
    rectangle([0,0],[16,32],colour=red),
    rectangle([48,0],[64,32],colour=red),
    curve([[0,0],[64,0],[64,32],[0,32],[0,0]])],scaling=constrained,axes=none);

Where are you getting this .33 and .66?  The expected value for Game A is not just a weighted sum of the expected values for Game B and Game C, because a turn of one game alters the distribution of the states for the other game.

Where are you getting this .33 and .66?  The expected value for Game A is not just a weighted sum of the expected values for Game B and Game C, because a turn of one game alters the distribution of the states for the other game.

Oops, silly of me... if f and g are not coprime, the resultant is 0, and then it's easy (you could e.g. take A = g and B=-f). 

Yes, you can use gcdex.  In fact you may as well use the 6-parameter form of gcdex:

 

> gcdex(f, g, resultant(f,g,x), x, 'A', 'B');

Oops, silly of me... if f and g are not coprime, the resultant is 0, and then it's easy (you could e.g. take A = g and B=-f). 

Yes, you can use gcdex.  In fact you may as well use the 6-parameter form of gcdex:

 

> gcdex(f, g, resultant(f,g,x), x, 'A', 'B');

Sorry if I didn't explain this enough.  Really, I'm trying to make it as simple as possible.

When your fortune is a multiple of 3, in Game B you use Coin 2 that always loses.  Therefore in Game B, you can't ever increase above a multiple of 3.
From 3*n you always go to 3*n-1, and then you throw Coin 3 that most of the time takes you back to 3*n.

Sorry if I didn't explain this enough.  Really, I'm trying to make it as simple as possible.

When your fortune is a multiple of 3, in Game B you use Coin 2 that always loses.  Therefore in Game B, you can't ever increase above a multiple of 3.
From 3*n you always go to 3*n-1, and then you throw Coin 3 that most of the time takes you back to 3*n.

It may be helpful to consider a more extreme case.  Suppose Coin 2 always loses, while Coin 3 wins with probability 1-e, 0 < e << 1, and Coin 1 wins with probability 1/2 - e.  Now in Game B it is impossible to increase your fortune above a multiple of 3; starting with 3*n, most of the time you would alternate between 3*n-1 and 3*n, but occasionally Coin 3 would lose twice in a row, so you get to 3*n-3, and then you're in the same position as before but with n replaced by n-1.  So in the long run, you certainly lose in Game B.

Now consider Game C, starting in a turn divisible by 3. 
If your current fortune is 3*n, then with probability almost 1/2 you win with Coin 1 and then twice with Coin 3, so at the start of the next turn divisible by 3 you are at 3*(n+1); with probability almost 1/2 you lose with Coin 1, then win with Coin 3, then lose with Coin 2, resulting in 3*n-1.
If your current fortune is 3*n+1, with probability almost 1/2 you win with Coin 1, win with Coin 3 and lose with Coin 2, resulting in 3*n+2, while with probability almost 1/2 you lose with Coin 1, lose with Coin 2 and win with Coin 3, resulting in 3*n.
If your current fortune is 3*n+2, with probability almost 1/2 you win with Coin 1, lose with Coin 2 and win with Coin 3, while with probability almost 1/2 you lose with Coin 1 and then win twice with Coin 3, in both cases resulting in 3*(n+1).
The result is that only rarely will your fortune be of the form 3*n+1 starting in a turn divisible by 3.  Either it will be 3*n+2, resulting with high probability in
3*n+3 three turns later, or it will be 3*n, resulting with high probability three turns later in either 3*n-1 (which, as I just mentioned, with high probability would go back to 3*n in another three turns) or 3*(n+1).  So in the long run, you win in Game C.   

 

 

It may be helpful to consider a more extreme case.  Suppose Coin 2 always loses, while Coin 3 wins with probability 1-e, 0 < e << 1, and Coin 1 wins with probability 1/2 - e.  Now in Game B it is impossible to increase your fortune above a multiple of 3; starting with 3*n, most of the time you would alternate between 3*n-1 and 3*n, but occasionally Coin 3 would lose twice in a row, so you get to 3*n-3, and then you're in the same position as before but with n replaced by n-1.  So in the long run, you certainly lose in Game B.

Now consider Game C, starting in a turn divisible by 3. 
If your current fortune is 3*n, then with probability almost 1/2 you win with Coin 1 and then twice with Coin 3, so at the start of the next turn divisible by 3 you are at 3*(n+1); with probability almost 1/2 you lose with Coin 1, then win with Coin 3, then lose with Coin 2, resulting in 3*n-1.
If your current fortune is 3*n+1, with probability almost 1/2 you win with Coin 1, win with Coin 3 and lose with Coin 2, resulting in 3*n+2, while with probability almost 1/2 you lose with Coin 1, lose with Coin 2 and win with Coin 3, resulting in 3*n.
If your current fortune is 3*n+2, with probability almost 1/2 you win with Coin 1, lose with Coin 2 and win with Coin 3, while with probability almost 1/2 you lose with Coin 1 and then win twice with Coin 3, in both cases resulting in 3*(n+1).
The result is that only rarely will your fortune be of the form 3*n+1 starting in a turn divisible by 3.  Either it will be 3*n+2, resulting with high probability in
3*n+3 three turns later, or it will be 3*n, resulting with high probability three turns later in either 3*n-1 (which, as I just mentioned, with high probability would go back to 3*n in another three turns) or 3*(n+1).  So in the long run, you win in Game C.   

 

 

> with(Statistics):
  X:= Sample(Normal(0, 0.5), 4) + I*Sample(Normal(0, 0.5), 4);
  ArrayTools:-Reshape(X,2,2);

 

First 49 50 51 52 53 54 55 Last Page 51 of 187