set.seed(67)
n <- 10000
B <- runif(n, min = 0, max = 1)
C <- runif(n, min = 0, max = 1)
cat("min(B)->", format(min(B), scientific = F), "max(B)->",max(B))
## min(B)-> 0.0001813229 max(B)-> 0.9998232
cat("min(c)->", format(min(C), scientific = F), "max(C)->",max(C))
## min(c)-> 0.00006529689 max(C)-> 0.9999409
# skewness of B
hist(B, probability = T, main = 'B histogram')
# skewness of C
hist(C, probability = T, main = 'C histogram')
Since the bins of both the histograms are evenly distributed, we can conclude B & C are proper probability distributions.
# The probability of B+C less than 1/2 is
a <- sum((B+C) < 0.5) / n
print(paste("The probability of B+C less than 1/2 is",a))
## [1] "The probability of B+C less than 1/2 is 0.1266"
# The probability of B*C less than 1/2 is
b <- sum((B*C) < 0.5) / n
print(paste("The probability of BC less than 1/2 is",b))
## [1] "The probability of BC less than 1/2 is 0.8428"
# The probability of |B-C| less than 1/2 is
c <- sum(abs(B-C) < 0.5) / n
print(paste("The probability of |B,C| less than 1/2 is",c))
## [1] "The probability of |B,C| less than 1/2 is 0.7592"
# The probability of max{B,C} less than 1/2 is
e <- sum(pmax(B,C) < 0.5) / n
print(paste("The probability of max{B,C} less than 1/2 is",e))
## [1] "The probability of max{B,C} less than 1/2 is 0.2536"
# The probability of min{B,C} less than 1/2 is
f <- sum(pmin(B,C) < 0.5) / n
print(paste("The probability of min{B,C} less than 1/2 is",f))
## [1] "The probability of min{B,C} less than 1/2 is 0.7444"