Choose independently two numbers B and C at random from the interval [0, 1] with uniform density. Prove that B and C are proper probability distributions. Note that the point (B,C) is then chosen at random in the unit square.

B <- runif(1000, min = 0, max = 1)
C <- runif(1000, min = 0, max = 1)

X <- B + C
productX <- B * C
absX <- abs(B - C)
maxX <- pmax(B, C)
minX <- pmin(B, C)

hist(X)

f_z1 <- function(x){x} #  for 0 < x < 1
f_z2 <- function(x){2-x} # for 

ans1 <- integrate(f_z1, 0, 1)
ans2 <- integrate(f_z2, 1, 2)
ans1
## 0.5 with absolute error < 5.6e-15
ans2
## 0.5 with absolute error < 5.6e-15

To be defined as a probabilty density funcion, the area under the curve must be equal to 1

total <- ans1$value + ans2$value
 
total
## [1] 1

Find the probability that:

(A) B + C = 1/2

f1 <- function(x){x}
integrate(f1, 0, 0.5)
## 0.125 with absolute error < 1.4e-15

(B) BC < 1/2

f_z3 <- function(x){-log(x)}
integrate(f_z3, 0, 0.5)
## 0.8465736 with absolute error < 1e-15

(C) |B-C| < 1/2

f_z4 <- function(x){2 * 1 - x}
integrate(f_z4, 0, 0.5)
## 0.875 with absolute error < 9.7e-15

(D) max(B,C) < 1/2

\[P(max(B,C)<1/2)~reduces~down~to~P(B<=1/2)*P(C<=1/2)=1/2 * 1/2 = 1/4\]

(E) min(B,C) < 1/2