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.

This probability distribution would require that both B and C are uniformily distributed between the interval [0, 1].

From the histograms below, we can see that f(B) and f(C) are both positive everywhere and that the area under the curve is 1 (as shown with the density plots), both requirements for propert probability distributions.

B <- runif(100000)
min(B)
## [1] 1.990958e-05
max(B)
## [1] 0.9999893
hist(B, probability = TRUE)

C <- runif(100000)
min(C)
## [1] 1.041219e-05
max(C)
## [1] 0.9999815
hist(C, probability = TRUE)

Find the probability that

  1. B + C < 1/2

We can confirm looking at the integrand of f(x) that the sum is 1

func1 <- function(x) {x}
func2 <- function(x) {2-x}
integrate(func1,0,1)
## 0.5 with absolute error < 5.6e-15
integrate(func2,1,2)
## 0.5 with absolute error < 5.6e-15
B <- runif(100000)
C <- runif(100000)
sum_random_numbers <- B + C
hist(sum_random_numbers, probability = TRUE)

B + C is a proper normal probability distributions.

sum <- 1
for(i in 1:length(B)){
  if(B[i]+C[i] < 0.5){
    sum = sum+1
  }
}
print(sum/length(B))
## [1] 0.12572

We can estimate the probabily using the integral of

\[\int_0^{.5} f(x)~dx\]

func1 <- function(x) {x}
func2 <- function(x) {2-x}
integrate(func1,0,.5)
## 0.125 with absolute error < 1.4e-15

The other probabilities are difficult to determing using integrals, but we can approximate the probabilty using simularions.

  1. BC < 1/2
B <- runif(100000)
C <- runif(100000)
multiply_random_numbers <- B * C
hist(multiply_random_numbers, probability = TRUE)

sum <- 1
for(i in 1:length(B)){
  if(B[i]*C[i] < 0.5){
    sum = sum+1
  }
}
print(sum/length(B))
## [1] 0.84614
  1. |B - C| < 1/2
B <- runif(100000)
C <- runif(100000)
abs_subtract_random_rumbers <- abs(B-C)
hist(abs_subtract_random_rumbers, probability = TRUE)

sum <- 1
for(i in 1:length(B)){
  if(abs(B[i]-C[i]) < 0.5){
    sum = sum+1
  }
}
print(sum/length(B))
## [1] 0.75047
  1. max(B + C) < 1/2
B <- runif(100000)
C <- runif(100000)
max_random_numbers <- c()
for(i in 1:length(B)){
  max <- max(B[i], C[i])
  max_random_numbers <- c(max, max_random_numbers)
}
hist(max_random_numbers)

sum <- 1
for(i in 1:length(B)){
  if(max(B[i], C[i]) < 0.5){
    sum = sum+1
  }
}
print(sum/length(B))
## [1] 0.24917
  1. min(B + C) < 1/2
B <- runif(100000)
C <- runif(100000)
max_random_numbers <- c()
for(i in 1:length(B)){
  min <- min(B[i], C[i])
  max_random_numbers <- c(min, max_random_numbers)
}
hist(max_random_numbers)

B <- runif(100000)
C <- runif(100000)

sum <- 1
for(i in 1:length(B)){
  if(min(B[i],C[i]) < 0.5){
    sum = sum+1
  }
}
print(sum/length(B))
## [1] 0.75014