Using an R function runif, we were able to generate a randomised set of values thousand times between 0 and 1, and assign these values to A and B. When we plot these A and B, we can clearly see that these are well distributed with a uniform density, proving that these are with proper probability distribution.
n = 1000
min = 0
max = 1
B = runif(n,min,max)
C = runif(n,min,max)
plot(B, xlab = 'index', ylab = 'B value')
plot(C, xlab = 'index', ylab = 'C value')
count <- 0
for (i in 1:n) {
if((B[i] + C[i]) < 0.5) {
count = count + 1
}
}
print(paste("The probability B+C less than 1/2 is ", count/n))
## [1] "The probability B+C less than 1/2 is 0.133"
count <- 0
for (i in 1:n) {
if((B[i] * C[i]) < 0.5) {
count = count + 1
}
}
print(paste("The probability BC less than 1/2 is ", count/n))
## [1] "The probability BC less than 1/2 is 0.848"
count <- 0
for (i in 1:n) {
if(abs(B[i] - C[i]) < 0.5) {
count = count + 1
}
}
print(paste("The probability BC less than 1/2 is ", count/n))
## [1] "The probability BC less than 1/2 is 0.745"
count <- 0
for (i in 1:n) {
if(max(B[i], C[i]) < 1/2) {
count = count + 1
}
}
print(paste("The probability max{B, C} less than 1/2 is ", count/n))
## [1] "The probability max{B, C} less than 1/2 is 0.262"
count <- 0
for (i in 1:n) {
if(min(B[i], C[i]) < 1/2) {
count = count + 1
}
}
print(paste("The probability min{B, C} less than 1/2 is ", count/n))
## [1] "The probability min{B, C} less than 1/2 is 0.767"