From: Jacob van Wyk <jlvw_at_na.rau.ac.za>

Date: Tue 01 Mar 2005 - 19:25:37 EST

c=c+1;

end

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Mar 01 19:33:16 2005

Date: Tue 01 Mar 2005 - 19:25:37 EST

Theoretically it is 1/4 - B is ahead on average with 25c.

I would start with, say,

sample(1:6,2,replace=T)

for one simulated roll of the two dice. I want to repeat this n times,
where n is, say, 10:2000 in steps of 10. Put the results in a matrix and
work columnwise - choosing when the first roll is even, selecting the
corresponding value of the second roll, and computing the payoff as
described, etc. But I need help to put this together.

In Matlab I would, for example, do the following to display the average payouts of A and B:

c=1;

samplesizes=[10:10:2000];

for s=samplesizes

rolls=ceil(6*rand(s,2));

a_pays_b_index=find(mod(rolls(:,1),2)==0); a_pays_b_value=rolls(a_pays_b_index,2); b_pays_a_index=find(mod(rolls(:,1),2)==1); b_pays_a_value=rolls(b_pays_a_index,1); a_pays_average(c)=mean(a_pays_b_value); b_pays_average(c)=mean(b_pays_a_value);

c=c+1;

end

Then do the plotting, etc. (One could also take differences, and so on.)

I would really appreciate if anybody would be kind enough to help. I thought it might be a nice example to introduce students (in general, perhaps - because it is a kind of interesting game) to simulation in R.

Thank you !

Jacob

(PS Any credit would be respected, i.e. my students will know who

helped me with this introduction.)

Jacob L van Wyk

Department of Mathematics and Statistics
University of Johannesburg APK

P O Box 524

Auckland Park 2006

South Africa

Tel: +27-11-489-3080

Fax: +27-11-489-2832

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Mar 01 19:33:16 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:30:38 EST
*