Robert Israel

6577 Reputation

21 Badges

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

MaplePrimes Activity


These are replies submitted by Robert Israel

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

 

Please explain the question.  I'm not sure what you mean.  Whether you define phi[0] or phi[0](z), diff(phi[0](z), z) should work.  On the other hand, if you define phi[0](z), Maple would not know what phi[0](t) or diff(phi[0](t),t) is.

Please explain the question.  I'm not sure what you mean.  Whether you define phi[0] or phi[0](z), diff(phi[0](z), z) should work.  On the other hand, if you define phi[0](z), Maple would not know what phi[0](t) or diff(phi[0](t),t) is.

I think you're looking at it from the wrong perspective.  Rather than joining the dots of the scatter plots, you want to join the lists of points that produce the scatter plots, and plot that as a curve.  Thus:

> with(Statistics): with(plots):
  X1:= [3.1, 4.1, 5.9, 2.6];
  Y1:= [5.3, 5.8, 9.7, 9.3];
  X2:= [2.7, 1.8, 2.8, 1.8];
  Y2:= [2.8, 4.5, 9.0, 4.2];
  Plot1:= ScatterPlot(X1,Y1,colour=red):
  Plot2:= ScatterPlot(X2,Y2,colour=blue);
  ptlist:= sort([op(zip(`[]`,X1,Y1)),op(zip(`[]`,X2,Y2))],(a,b)->(a[1]<b[1]));
  display([Plot1, Plot2, plot(ptlist, colour=green)]);

I think you're looking at it from the wrong perspective.  Rather than joining the dots of the scatter plots, you want to join the lists of points that produce the scatter plots, and plot that as a curve.  Thus:

> with(Statistics): with(plots):
  X1:= [3.1, 4.1, 5.9, 2.6];
  Y1:= [5.3, 5.8, 9.7, 9.3];
  X2:= [2.7, 1.8, 2.8, 1.8];
  Y2:= [2.8, 4.5, 9.0, 4.2];
  Plot1:= ScatterPlot(X1,Y1,colour=red):
  Plot2:= ScatterPlot(X2,Y2,colour=blue);
  ptlist:= sort([op(zip(`[]`,X1,Y1)),op(zip(`[]`,X2,Y2))],(a,b)->(a[1]<b[1]));
  display([Plot1, Plot2, plot(ptlist, colour=green)]);

Possibly better: use plotsetup to produce the plot in gif or jpg format.  In this method you can set the height and width of the plot in pixels.  Thus:

> plot(whatever...); 
  MYPLOT:= %:
  plotsetup(jpeg, plotoutput="c:/myfolder/myplot.jpg", plotoptions="height=500,width=640");
  MYPLOT;
  plotsetup(default);

Then it can be inserted into your worksheet using the menu choices Insert, Image...

 

Possibly better: use plotsetup to produce the plot in gif or jpg format.  In this method you can set the height and width of the plot in pixels.  Thus:

> plot(whatever...); 
  MYPLOT:= %:
  plotsetup(jpeg, plotoutput="c:/myfolder/myplot.jpg", plotoptions="height=500,width=640");
  MYPLOT;
  plotsetup(default);

Then it can be inserted into your worksheet using the menu choices Insert, Image...

 

I used the values quoted in the Wikipedia article.  If you changed the 0.495 to 0.5, game A would be fair rather than unfavourable.

Here is my explanation of how it works.  In game B, then your fortune mod 3 is described by a 3-state Markov chain with transition matrix

       0    1     2 
   -----------------
0  | 0    .095  .905
1  | .255   0   .745
2  | .745 .255    0
  
> PB := Matrix([[0, .095, .905], [.255,0,.745], [.745,.255,0]]);

The equilibrium probabilities for the three states are given by the normalized left eigenvector for eigenvalue 1:

> op(LinearAlgebra:-NullSpace(PB^%T-1));
  V := %/(%[1]+%[2]+%[3]);
     [.383611758995063]
V := [.154280572558398]
     [.462107668446539]

Thus in the long run you will be in state 0, and thus using the unfavourable Coin 2, more than 38% of the time,  The expected gain per throw is
then

> V[1]*(.095 - .905) + (1 - V[1])*(.745 - .255);

-.00869528669358172

so game B is slightly unfavourable.

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
(and thus the probability that you would be throwing Coin 2).  Apparently it does so enough so that the game becomes favourable.  Let's see...

The transition matrix for game A is

> PA := Matrix([[0, .495, .505], [.505, 0, .495], [.495, .505, 0]]);

For three turns of game C (starting with a Game A turn), the transition matrix is PB^2 PA:

> PC := PA . PB^2 ;
      [.307575000000000, .141770375000000, .550654625000000 ] 
PC := [.384904625000000, .151575000000000, .463520375000000 ]
      [.626020375000000, .222404625000000, .151575000000000 ]

The equilibrium vector for this is
 

      [.442933884975660]
VC := [.174340510410703]
      [.382725604613637]

The expected gain in a three-turn cycle is then

.495 - .505 = -.01 for the Game A turn

(VC^%T .PA)[1]*(.095 - .905)+ (1 - (VC^%T . PA)[1])*(.745 - .255) = ..129261528346498 for the next (Game B) turn

(VC^%T . PA . PB)[1]*(.095 - .905) + (1 - (VC^%T . PA . PB)[1])*(.745 - .255)  = .0530309454430971 for the following (Game B) turn

for a total of .172292473789595. 

This fits pretty well with the simulation: in 20000 turns of Game C the expected value would be approximately
20000/3*.172292473789595 = 1148.6, as opposed to 20000*(-.01) = -200 for Game A and 20000*(-.00869528669358172) = -173.9 for Game B.
 

I used the values quoted in the Wikipedia article.  If you changed the 0.495 to 0.5, game A would be fair rather than unfavourable.

Here is my explanation of how it works.  In game B, then your fortune mod 3 is described by a 3-state Markov chain with transition matrix

       0    1     2 
   -----------------
0  | 0    .095  .905
1  | .255   0   .745
2  | .745 .255    0
  
> PB := Matrix([[0, .095, .905], [.255,0,.745], [.745,.255,0]]);

The equilibrium probabilities for the three states are given by the normalized left eigenvector for eigenvalue 1:

> op(LinearAlgebra:-NullSpace(PB^%T-1));
  V := %/(%[1]+%[2]+%[3]);
     [.383611758995063]
V := [.154280572558398]
     [.462107668446539]

Thus in the long run you will be in state 0, and thus using the unfavourable Coin 2, more than 38% of the time,  The expected gain per throw is
then

> V[1]*(.095 - .905) + (1 - V[1])*(.745 - .255);

-.00869528669358172

so game B is slightly unfavourable.

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
(and thus the probability that you would be throwing Coin 2).  Apparently it does so enough so that the game becomes favourable.  Let's see...

The transition matrix for game A is

> PA := Matrix([[0, .495, .505], [.505, 0, .495], [.495, .505, 0]]);

For three turns of game C (starting with a Game A turn), the transition matrix is PB^2 PA:

> PC := PA . PB^2 ;
      [.307575000000000, .141770375000000, .550654625000000 ] 
PC := [.384904625000000, .151575000000000, .463520375000000 ]
      [.626020375000000, .222404625000000, .151575000000000 ]

The equilibrium vector for this is
 

      [.442933884975660]
VC := [.174340510410703]
      [.382725604613637]

The expected gain in a three-turn cycle is then

.495 - .505 = -.01 for the Game A turn

(VC^%T .PA)[1]*(.095 - .905)+ (1 - (VC^%T . PA)[1])*(.745 - .255) = ..129261528346498 for the next (Game B) turn

(VC^%T . PA . PB)[1]*(.095 - .905) + (1 - (VC^%T . PA . PB)[1])*(.745 - .255)  = .0530309454430971 for the following (Game B) turn

for a total of .172292473789595. 

This fits pretty well with the simulation: in 20000 turns of Game C the expected value would be approximately
20000/3*.172292473789595 = 1148.6, as opposed to 20000*(-.01) = -200 for Game A and 20000*(-.00869528669358172) = -173.9 for Game B.
 

This can all be done easily using map.  For the first example,

> map[inplace](t -> `if`(t=3.5, 3.7, t), b);

For the second,

> map[inplace](t -> `if`(t < 3.8 and t > 3.2, 3.5, 0), b);

More generally, the entropy of a discrete probability measure P with atoms x_i is sum_i -P(x_i) ln(P(x_i)).  There are many definitions of entropy in different contexts.  See e.g. eom.springer.de/E/e035740.htm.

 

More generally, the entropy of a discrete probability measure P with atoms x_i is sum_i -P(x_i) ln(P(x_i)).  There are many definitions of entropy in different contexts.  See e.g. eom.springer.de/E/e035740.htm.

 

1) you have assmue instead of assume.

2) the plot includes some very large values very close to l=0.  You can specify an interval for the y axis, or display with the view option.

1) you have assmue instead of assume.

2) the plot includes some very large values very close to l=0.  You can specify an interval for the y axis, or display with the view option.

B is the constant term in the series.  Thus it is the limit of your expression as sigma -> 0. 

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