• Home
  • About R Trix
  • Teaching Resources
  • RTricks Library
  • Interactive Apps
  • Training Network
RTFR landingdist

R Output for Discrete Probability Example 2

> prob1.the <- (12/31) * (12/31)

> result <- rep(0, 10000)

> for (i in 1:10000) {

> trial1 <- sample(1:31, size = 2, replace = T)

> if ((trial1[1] < 13) & (trial1[2] < 13))

> result[i] <- 1

> }

> prob1.sim <- sum(result)/10000

> prob1.sim

0.146

> prob2.the <- (12/31) * (11/30)

> prob2.the

0.141935483870968

> result <- rep(0, 10000)

> for (i in 1:10000) {

> trial2 <- sample(1:31, size = 2, replace = F)

> if ((trial2[1] < 13) & (trial2[2] < 13))

> result[i] <- 1

> }

> prob2.sim <- sum(result)/10000

> prob2.sim

0.1412