MrMarc

3158 Reputation

18 Badges

16 years, 267 days

MaplePrimes Activity


These are answers submitted by MrMarc

but that is another thing:

add(.5, x = 0 .. 7);
                                     4.0
0.5*7;
                                     3.5
??

ok, thanx. Yes, you might be right.  I forgot that you lose 1 on the length  ie  0.5*( 7-1) =0.5*6 =3.
It would have been easier though if the length would have been the same ie
a starting point of zero ie 0.5*( 7-0) =0.5*7 =3.5 but then I guess add would produce 4 humm..

I think it has something to do with the fact that the standard deviation of the
price distribution at time t for a randomwalk increases with sqrt(time) = time^0.5 hummm... 

I would be gratful if anyone could please explain to me why the
covariance function is assumed to take the form :
 

(t[i]^(2*H)+t[j]^(2*H)-abs(t[i]-t[j])^(2*H))/2)

 

A moving average sounds like the tool you want ?!


restart:
randomize():
with(plots):
with(Statistics):

a := 0:  b := 1:  n := 500:  mov := 50:

r := Sample(RandomVariable(Normal(0, 3)), n):

s[1] := 100:   for i from 2 to n do s[i] := a+b*s[i-1]+r[i] end do:

ss := [seq(s[i], i = 1 .. n)]:
tt := [seq(i, i = 1 .. n)]:

A1 := plot(tt, ss, color = black, thickness = 2):
A2 := plot(tt[mov .. n], MovingAverage(ss, mov), color = green, thickness = 3):
display({A1, A2});
 

ok thank you. Does there exist any alternative methods ?
I read something about introducing an auxiliary variable

Well I want the simulation to tell me that the maximum is 2/3. If you simply put

X:= proc(pp)
      uses Statistics;
      local c,a,b, C, S, T, i;
      if pp <= 2/3 then c:= 0 else c:= 1 end if; # player 2's best strategy against pp

then you are kind of forcing the simulation to have a maximum at 2/3. If you put 0.2 instead there
then the maximum will be 0.2 etc . The idea was that we dont know the optimal strategy for player 1
which we will hopefully find though simulation :-)

Thanks Robert :-) Stable as usual !!  I will have a look at your code and get back to you with questions.

" I don't understand what you're trying to do in your simulation.  What strategy is Player 2 supposed to be using?"

As you might have noticed I am a bit confussed when it comes to this problem. I read in the pdf file
that:  "Player 2 is assumed to know the value of x1". Hence in my simulation code I had 1-pp

c1 := Sample(RandomVariable(Bernoulli(pp)), 1)[1]:    # selection player 1
c2 := Sample(RandomVariable(Bernoulli(1-pp)), 1)[1]:   # selection player 2

but that code did not work very well. I have another piece of code that shows that the maximum occurs
when player one randomly (p=0.5) is switching between Action2 and Action4. 
The expected value player1 is given by:

[Expected Value Player 1]        Player2=pass     Player2=play
Player1=Action2                            [ +1 ]                           [ 0 ]
Player1=Action4                             [ 0 ]                            [ 0.5 ]


Hence when Player1 selects Action2 most of the time Player2 will play ( otherwise expected value player2 =-1)
and when Player1 selects Action4  most of the time Player2 will pass ( otherwise expected value player2 =-0.5)
unless player1 is "bluffing" which is unlikely but it can happen. I am not sure it is correct though hummm

restart:
with(LinearAlgebra):
with(plots):
with(Statistics):
randomize():

X := proc (pp) local c1, c2, cc, E1, E2;

c1 := Sample(RandomVariable(Bernoulli(pp)), 1)[1]:
c2 := Sample(RandomVariable(Bernoulli(1-pp)), 1)[1]:

E1 := 0:

if c1 = 0 and c2 = 1 then E1 := 0:                    # Player1=Action2  Player2=Play  ->  Player1 Expected Value=0
elif c1 = 0 and c2 = 0 then E1 := 1;  end if:    # Player1=Action2  Player2=Pass  ->  Player1 Expected Value= +1  (Bluffing)

if c1 = 1 and c2 = 0 then E1 := 0;                     # Player1=Action4  Player2=Pass  ->  Player1 Expected Value=0
elif c1 = 1 and c2 = 1 then E1 := .5;  end if:    # Player1=Action4  Player2=Play   ->  Player1 Expected Value= +0.5  (Bluffing)

E1 ;

end proc:

listplot([seq([pp, ExpectedValue([seq(X(pp), i = 1 .. 200)])], pp = 0 .. 1, 0.5e-1)], color = red, thickness = 3, title = "Player1 \n", titlefont = [times, roman, 16], labels = ["Probability Action4", "Expected Value"], labelfont = [times, roman, 14], labeldirections = [horizontal, vertical]);






The only two ways that I can think of that player1 can bluff and gain an advantage are:

1.A)  Player1 select Action2; Play on head and Play on Tail
1.B) When he gets tail he pass instead of betting (ie Action4); Player1=-1  and Player2=+1
1.D) If Player1 would not have bluffed the outcome would have been;  Player1=-2  and Player2=+2
1.E) Which means that Player1 has gained +1 by bluffing.

2.A)  Player1 select Action4; Play on head and Pass on Tail
2.B) When he gets tail he bets instead of passing (ie Action2)
2.C) Player2 thinks player1 sticks to Action4 so player2 pass;  Player1=+1  and Player2=-1
2.D) If Player1 would not have bluffed the outcome would have been;  Player1=-1  and Player2=+1
2.E) Which means that Player1 has gained +2 by bluffing.
 


restart:
with(DEtools):
with(plots):

d1 := diff(x(t), t) = x(t)*(7-x(t)-2*y(t)):
d2 := diff(y(t), t) = y(t)*(5-y(t)-x(t)):

sys := {d1, d2};

nullcline := eval(sys, {x(t) = x, y(t) = y, diff(x(t), t) = 0, diff(y(t), t) = 0}):
map(isolate, nullcline, y):
window := x = 1 .. 5, y = 1 .. 4:

A1 := DEplot(sys, [x(t), y(t)], t = 0 .. 1, window, arrows = medium):
A2 := display(map(implicitplot, nullcline, window, color = GREEN, thickness = 3)):

display({A1, A2});



I tried the following code but it does not work !  The maximum is not located at p(x1)=0.67
very strange....hummm...

restart:
with(LinearAlgebra):
with(plots);
with(Statistics):
randomize():

X := proc (pp) local c1, c2, cc, E1, E2;

c1 := Sample(RandomVariable(Bernoulli(pp)), 1)[1]:
c2 := Sample(RandomVariable(Bernoulli(1-pp)), 1)[1]:

E1 := 0;

if c1 = 1 and c2 = 1 then E1 := 0
elif c1 = 1 and c2 = 0 then E1 := .5   end if:

if c1 = 0 and c2 = 1 then E1 := 1
elif c1 = 0 and c2 = 0 then E1 := 0  end if:

E1 ;

end proc:


listplot([seq([pp, ExpectedValue([seq(X(pp), i = 1 .. 50)])], pp = 0 .. 1, 0.5e-1)]);
 

The problem might be that Maple is designed for Microsoft SQL Server 2005 Express but I 
am using Microsoft SQL Server 2008 Express hence the error messages "Unknown API type".
However, I find it a bit strange that Maple cant handle different version of the same software....humm

pretty neat :-)  I wonder if we can use the new Maple fly though feature to look at the data in closeup ?!

restart:
A := Matrix([[2, 3, 5], [9, 2, 1], [5, 1, 2], [1, 8, 9]]):
A[[1, 3], 1 .. 3];
                           
                                  [2  3  5]
                                  [5  1  2]
 

"Now if you play a turn of game A, even though that is unfavourable in itself, it decreases the probability that your fortune will be 0 mod 3 in the next turns." How does playing game A make it less likely that fortune will be a multiple of 3?

Good question :-)  I do not know the answer to that question.

In game B which has Capital mod 3 =0 and  Capital mod 3 <>0 as conditions for selection the two coins we get the following:

If your current capital is 3 6 9 12  then capital mod =0 which means that you are forced to use the "bad coin" (coin 2, you will most likely lose in the next turn). In such a situation you would benefit from losing 1 because then you would get down to capital 2 5 8 11 (capital mod 3 <> 0, best coin, coin 3, you will most likely win in the next turn) but you would also benefit from gaining 1 because then you would get up to capital 4  7 10 13 (capital mod 3 <> 0, best coin, coin 3, you will most likely win in the next turn).

Please also note that in the diagram in the post called  "That is perfect Robert :-)  "  There are two errors in that picture. It says

if t mod 3=1
if Capital mod 3=1

it should  be:      if t mod 3<>0     if Capital mod 3<>0 

I used the remainder notation (modulo operation mod) in the wrong way there. The reminder can be both 1, 2 etc so it does not make sense. If you specify it as   if t mod 3<>0     if Capital mod 3<>0   it does however make sense :-)

all right thanx. I have done some other work here (very nice with sliders etc).
but it is difficult to put my finger on the exact mechanics (it does not work properly) that makes it tick..humm

View 8342_ParronXX.mw on MapleNet or Download 8342_ParronXX.mw
View file details

 

2 3 4 5 6 7 8 Last Page 4 of 24