We will use the runif function in R to pick two numbers from the interval [0,1] with uniform density. In looking at B, we can see that this is a proper probability distribution as we pulled 100,000 different probabilities and 100% of them fall within the interval [0,1]. Additionally, we can see that this is a uniform distribution.
B <- runif(100000)
hist(B)
The same is true of C:
C <- runif(100000)
hist(C)
As both values fall within the interval [0,1], the combined interval with fall between [0,2] 100% of the time.
We will use a simlulation to solve the questions below. Given that we have 100K probabilities for both B and C, the law of large numbers should help us get incredibly close to the probabliity we would have calculated manually.
counter <- 0
for (i in seq(length(B))) {
if (B[i] + C[i] < 0.5) {
counter <- counter + 1
} else {
next()
}
}
prob1 <- counter / length(B)
counter <- 0
for (i in seq(length(B))) {
if (B[i] * C[i] < 0.5) {
counter <- counter + 1
} else {
next()
}
}
prob2 <- counter / length(B)
counter <- 0
for (i in seq(length(B))) {
if (abs(B[i] - C[i]) < 0.5) {
counter <- counter + 1
} else {
next()
}
}
prob3 <- counter / length(B)
counter <- 0
for (i in seq(length(B))) {
if (max(B[i], C[i]) < 0.5) {
counter <- counter + 1
} else {
next()
}
}
prob4 <- counter / length(B)
counter <- 0
for (i in seq(length(B))) {
if (min(B[i], C[i]) < 0.5) {
counter <- counter + 1
} else {
next()
}
}
prob5 <- counter / length(B)