> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Jaap van Wyk
> Sent: 30 August 2011 04:57
> To: [email protected]
> Subject: [R] Simulating distribution of max of two die
>
> how to find the distribution of the
> maximum of rolling two balanced die. Is there perhaps a more
> elegant way to do this, other than the way I am using below?
#Perhaps
dice <- matrix(sample(1:6, 40000,replace=T), ncol=2)
dice.max <- apply(dice, 1, max)
barplot(table(dice.max))
#and just for interest
mids<-barplot(table(dice.max)/length(dice.max)) #gives proportions
all.pairs <- expand.grid(1:6, 1:6)
dice.max.exact <- apply(all.pairs, 1, max)
points(mids, table(dice.max.exact)/36, pch="_", cex=2, col=2)
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.