Joe Riel

9660 Reputation

23 Badges

20 years, 17 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Assume player A has a score of x (x pounds).  After a turn, his expected score is E(x) = 1/2*(x-1) + 1/2*(x+1) = x.  So his expected score is constant throughout the game.  Let p(x) be the probability that A wins (obtains all the cash).  His expected score is then p(x)*total + (1-p(x))*0 = p(x)*total. But from the previous observation, this equals his current score.  So p(x)*total = x, hence p(x) = x/total.

Assume player A has a score of x (x pounds).  After a turn, his expected score is E(x) = 1/2*(x-1) + 1/2*(x+1) = x.  So his expected score is constant throughout the game.  Let p(x) be the probability that A wins (obtains all the cash).  His expected score is then p(x)*total + (1-p(x))*0 = p(x)*total. But from the previous observation, this equals his current score.  So p(x)*total = x, hence p(x) = x/total.

The -hold comes because if you roll a one you lose whatever you had in the hold. If you roll another number, then you add that number to the hold.  The expected is the sum of the probabilty of each event multiplied by its value.  So

 Eroll = P(1)*(-hold) + P(2)*2 + ... P(6)*6 = 1/6*(-hold + 20)

The solution of the gamblers problem is Pa = 7/(7+13).  This is a standard martingale problem. A nice monograph on the subject is "Random Walks and Electric Networks," by Doyle and Snell, published by the MAA.

The -hold comes because if you roll a one you lose whatever you had in the hold. If you roll another number, then you add that number to the hold.  The expected is the sum of the probabilty of each event multiplied by its value.  So

 Eroll = P(1)*(-hold) + P(2)*2 + ... P(6)*6 = 1/6*(-hold + 20)

The solution of the gamblers problem is Pa = 7/(7+13).  This is a standard martingale problem. A nice monograph on the subject is "Random Walks and Electric Networks," by Doyle and Snell, published by the MAA.

Maple isn't required to compute the strategy that maximizes the expected score of a turn. 

There is only one strategic decision, that is, selecting the minimal score required to stop.  Suppose you have accumulated hold points.  If you stop at that point your score is hold.  If you play one more turn then hold either becomes 0 [if you roll a 1], hold+2 if you roll a 2, etc.  So the expected value of that roll is

  Eroll = 1/6*( - hold + 2 + 3 ... + 6) = (20 - hold)/6

To maximize the expected value of a turn, continue so long as Eroll > 0.  That is, the strategy that maximizes the expected return of a turn is to continue rolling until you reach 20 points [or bust].

In the actual game, which concludes when either player reaches 100, the optimal strategy is not necessarily to maximize your expected score on each turn.  Clearly, if you are trailing near the end of the game it is worthwhile to go for a bigger score, otherwise your opponent will likely win on the next turn.  Computing the precise strategy given the score is non-trivial.

Here is a simple Maple progam that models one turn

pig := module()
export die, turn;
    die := rand(1..6);
    turn := proc(mn)
    local tot, roll;
        tot := 0;
        while tot < mn do
            roll := die();
            if roll = 1 then
                return 0;
            else
                tot := tot+roll;
            end if;
        end do;
        return tot;
    end proc:
end module:

Plot the simulated score of one turn, as the minimum stopping point varies from 2 to 40.

N := 10\000:
plot([seq([mn, add(pig:-turn(mn), i=1..N)/N], mn=2..40)]);

Maple isn't required to compute the strategy that maximizes the expected score of a turn. 

There is only one strategic decision, that is, selecting the minimal score required to stop.  Suppose you have accumulated hold points.  If you stop at that point your score is hold.  If you play one more turn then hold either becomes 0 [if you roll a 1], hold+2 if you roll a 2, etc.  So the expected value of that roll is

  Eroll = 1/6*( - hold + 2 + 3 ... + 6) = (20 - hold)/6

To maximize the expected value of a turn, continue so long as Eroll > 0.  That is, the strategy that maximizes the expected return of a turn is to continue rolling until you reach 20 points [or bust].

In the actual game, which concludes when either player reaches 100, the optimal strategy is not necessarily to maximize your expected score on each turn.  Clearly, if you are trailing near the end of the game it is worthwhile to go for a bigger score, otherwise your opponent will likely win on the next turn.  Computing the precise strategy given the score is non-trivial.

Here is a simple Maple progam that models one turn

pig := module()
export die, turn;
    die := rand(1..6);
    turn := proc(mn)
    local tot, roll;
        tot := 0;
        while tot < mn do
            roll := die();
            if roll = 1 then
                return 0;
            else
                tot := tot+roll;
            end if;
        end do;
        return tot;
    end proc:
end module:

Plot the simulated score of one turn, as the minimum stopping point varies from 2 to 40.

N := 10\000:
plot([seq([mn, add(pig:-turn(mn), i=1..N)/N], mn=2..40)]);

Rather than [seq(cat(x,k), k=1..3)]  you can use [cat(x, 1..3)].

Rather than [seq(cat(x,k), k=1..3)]  you can use [cat(x, 1..3)].

Here's a cute way to generate that string:

  cat("", cat(1..5, "\n"));

I generally use StringTools:-Join to avoid the final newline:

  StringTools:-Join([cat("",1..5)],"\n");

That is preferable to stripping a final newline because that fails if the 5 is actually a parameter that evalutes to 0.

Here's a cute way to generate that string:

  cat("", cat(1..5, "\n"));

I generally use StringTools:-Join to avoid the final newline:

  StringTools:-Join([cat("",1..5)],"\n");

That is preferable to stripping a final newline because that fails if the 5 is actually a parameter that evalutes to 0.

How are you defining abs(1,z) for z complex?  The conjugate is not analytic, so I don't see how you hope to define a complex derivative for it.  Maybe you mean that for z real, -conjugate(z)/z + 2*abs(1,z)/signum(z) reduces to 1, but I don't see how you do that otherwise.

It is curious that z and conjugate(z) are considered independent; they are no more independent than z and -z.

How are you defining abs(1,z) for z complex?  The conjugate is not analytic, so I don't see how you hope to define a complex derivative for it.  Maybe you mean that for z real, -conjugate(z)/z + 2*abs(1,z)/signum(z) reduces to 1, but I don't see how you do that otherwise.

It is curious that z and conjugate(z) are considered independent; they are no more independent than z and -z.

So what do you want?  diff(conjugate(z), z) is not defined.

So what do you want?  diff(conjugate(z), z) is not defined.

f := z + conjugate(z)^2;
frontend(diff, [f,conjugate(z)]);  
                                        _
                                      2 z

First 111 112 113 114 115 116 117 Last Page 113 of 195