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(10000, min = 0, max = 1)
head(B)
## [1] 0.38246942 0.20466793 0.69976452 0.14801633 0.02812917 0.60121816
C <- runif(10000, min = 0, max = 1)
head(C)
## [1] 0.71916545 0.03131397 0.51844817 0.75983000 0.94767657 0.82566129
head(B+C)
## [1] 1.1016349 0.2359819 1.2182127 0.9078463 0.9758057 1.4268794
a <- sum((B+C) < .5)/10000
print(paste("The probability that B+C will be less than 1/2 is",a))
## [1] "The probability that B+C will be less than 1/2 is 0.1235"
b <- (sum((B*C) < .5)/10000)
print(paste("The probability that B*C will be less than 1/2 is",b))
## [1] "The probability that B*C will be less than 1/2 is 0.8455"
j = 0
for(i in 1:length(B)){
if(abs(B[i]-C[i]) < 0.5){
j = j+1
}
}
print(paste("The Probabilty |B-C| < 1/2 =", j/length(B)))
## [1] "The Probabilty |B-C| < 1/2 = 0.7477"
x <- 0
for(i in 1:10000){
if(max(c(B[i],C[i])) < 0.5){
x = x+1
}
}
d <- x/10000
print(paste("The probability that max{B,C} will be less than 1/2 is",d))
## [1] "The probability that max{B,C} will be less than 1/2 is 0.251"
x <- 0
for(i in 1:10000){
if(min(c(B[i],C[i])) < 0.5){
x = x+1
}
}
e <- x/10000
print(paste("The probability that min{B,C} will be less than 1/2 is",e))
## [1] "The probability that min{B,C} will be less than 1/2 is 0.7506"