Choose independently two numbers B and C at random from the interval [0, 1] with uniform density.
## Warning: package 'dplyr' was built under R version 3.5.3
## Warning: package 'ggplot2' was built under R version 3.5.3
## Warning: package 'ggthemes' was built under R version 3.5.3
set.seed(12345)
n <- 1000000
B <- runif(n, min = 0, max = 1)
C <- runif(n, min = 0, max = 1)
data <- data.frame(B = B, C = C)Note that the point (B,C) is then chosen at random in the unit square.
Find the probability that
## [1] 0.125473
This is represented by the area in blue
ggplot(data, aes(x = B, y = C, color = as.factor(a))) +
geom_point() +
coord_cartesian(xlim = c(0, 1), ylim = c(0, 1)) +
scale_color_fivethirtyeight() +
theme_fivethirtyeight() + ylab('C') + xlab('B') +
theme(legend.position = "none", aspect.ratio=1) ## [1] 0.846341
ggplot(data, aes(x = B, y = C, color = as.factor(b))) +
geom_point() +
coord_cartesian(xlim = c(0, 1), ylim = c(0, 1)) +
theme(legend.position = "none", aspect.ratio=1) +
scale_color_fivethirtyeight() +
theme_fivethirtyeight() + ylab('C') + xlab('B') +
theme(legend.position = "none", aspect.ratio=1) ## [1] 0.749999
ggplot(data, aes(x = B, y = C, color = as.factor(c))) +
geom_point() +
coord_cartesian(xlim = c(0, 1), ylim = c(0, 1)) +
theme(legend.position = "none", aspect.ratio=1) +
scale_color_fivethirtyeight() +
theme_fivethirtyeight() + ylab('C') + xlab('B') +
theme(legend.position = "none", aspect.ratio=1) ## [1] 0.250294
ggplot(data, aes(x = B, y = C, color = as.factor(d))) +
geom_point() +
coord_cartesian(xlim = c(0, 1), ylim = c(0, 1)) +
theme(legend.position = "none", aspect.ratio=1) +
scale_color_fivethirtyeight() +
theme_fivethirtyeight() + ylab('C') + xlab('B') +
theme(legend.position = "none", aspect.ratio=1) ## [1] 0.749954
ggplot(data, aes(x = B, y = C, color = as.factor(e))) +
geom_point() +
coord_cartesian(xlim = c(0, 1), ylim = c(0, 1)) +
theme(legend.position = "none", aspect.ratio=1) +
scale_color_fivethirtyeight() +
theme_fivethirtyeight() + ylab('C') + xlab('B')