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.

We can create two random variables, \(B\) and \(C\), by sampling 200,000 numbers between 0 and 1.

n <- 100000
B <- as.data.frame(runif(n, min=0, max=1))
C <- as.data.frame(runif(n, min=0, max=1))

We see a uniform density when we plot \(B\) and \(C\). The range of both values is between 0 and 1.

ggplot(B, aes(x=B[1])) + 
  geom_density() +
  labs(title = "Density Plot of Random Value B (n = 100,000)", x = "Random Values")

ggplot(C, aes(x=C[1])) + 
  geom_density() +
  labs(title = "Density Plot of Random Value C (n = 100,000)", x = "Random Values")


Find the probability that:

(a) \(B + C < \frac{1}{2}\)

The probability that \(B + C\) is below \(0.5\) is equal to the area created by the triangle below \(0.5\) in the density curve. This is a simple calculation since the base and height of this triangle is equal to \(0.5\), so the area is \(0.5^3 = 0.125\).

# Create an array with the sum of B and C, and plot the density
sum_bc <- B[1] + C[1]

ggplot(C, aes(sum_bc)) + 
  geom_density() +
  labs(title = "Density Plot of B + C", x = "Sum of Random Values")

We see a similar result when we use the punif function to calculate the probability of \(B + C < 0.5\) given a uniform distribution.

prob_a <- sum(punif((B+C)<0.5, min=0, max=1)) / n
print(sprintf("The probability that is %f percent", prob_a*100))
## [1] "The probability that is 12.399000 percent"

The probability that the sum of B and C falls below \(\frac{1}{2}\) is about 12.6%.




(b) \(B \times C < \frac{1}{2}\)

# Create an array with the product of B times C, and plot of the density
prod_bc <- B[1] * C[1]

ggplot(C, aes(prod_bc)) + 
  geom_density() +
  labs(title = "Density Plot of B * C", x = "Product of Random Values")

# Calculate the probability that B * C < 0.5
prob_b <- sum(punif((B*C)<0.5, min=0, max=1))/n
print(sprintf("The probability is %f percent", prob_b*100))
## [1] "The probability is 84.740000 percent"

The probability that the product of B and C falls below \(\frac{1}{2}\) is about 85%.




(c) \(|B - C| < \frac{1}{2}\)

# Create an array with the difference of B - C, and plot of the density
diff_bc <- abs(B[1] - C[1])

ggplot(C, aes(diff_bc)) + 
  geom_density() +
  labs(title = "Density Plot of |B - C|", x = "Difference of Random Values")

# Calculate the probability that |B - C| < 0.5
prob_c <- sum(punif((abs(B-C))<0.5, min=0, max=1))/n
print(sprintf("The probability is %f percent", prob_c*100))
## [1] "The probability is 74.730000 percent"

The probability that the difference of B and C falls below \(\frac{1}{2}\) is about 75%.




(d) \(\text{max}\{B, C\} < \frac{1}{2}\)

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

# Set a counter
count_max <- 1

# Loop through each point in (B, C) to find the maxes below 0.5
for(i in 1:length(B)){
  if(max(B[i], C[i]) < 0.5){
    count_max = count_max + 1
  }
}

print(count_max / n)
## [1] 0.24828

The probability that the maximum value of either \(B\) or \(C\) falls below \(\frac{1}{2}\) is about 25%.




(d) \(\text{min}\{B, C\} < \frac{1}{2}\)

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

# Set a counter
count_min <- 1

# Loop through each point in (B, C) to find the mins below 0.5
for(i in 1:length(B)){
  if(min(B[i], C[i]) < 0.5){
    count_min = count_min + 1
  }
}

print(count_min / n)
## [1] 0.7488

The probability that the minimum value of either \(B\) or \(C\) falls below \(\frac{1}{2}\) is 75%.