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.
Find the probability of a,b,c,d,e:
First, let’s create the two numbers B,C at random from the inverval [0,1] with uniform density.
B.nums <- runif(10000, min=0, max=1)
C.nums <- runif(10000, min=0, max=1)
B <- as.data.frame(B.nums)
C <- as.data.frame(C.nums)
To prove that B, C are proper probability distributions:
summary.B <- B %>%
mutate(condition.1 <- ifelse(B > 0 && B <= 1,TRUE,FALSE)) %>% # create `condition.1` column that fills as True if 0 < B <= 1, otherwise False.
setNames(c("B", "condition.1")) %>% # rename columns
group_by(condition.1) %>% # group by the condition.1 column
tally() # table summary.
summary.C <- C %>%
mutate(condition.1 <- ifelse(B > 0 && B <= 1,TRUE,FALSE)) %>%
setNames(c("C", "condition.1")) %>%
group_by(condition.1) %>%
tally()
sum.b <- sum(B)
sum.c <- sum(C)
paste("Total value of B: " , nrow(B) )
## [1] "Total value of B: 10000"
paste("Number of B values that is between 0 and 1 inclusive: ", summary.B[2])
## [1] "Number of B values that is between 0 and 1 inclusive: 10000"
paste("Total value of C: " , nrow(C) )
## [1] "Total value of C: 10000"
paste("Number of C values that is between 0 and 1 inclusive: ", summary.C[2])
## [1] "Number of C values that is between 0 and 1 inclusive: 10000"
outcome.b <- B %>%
mutate(prob.b <- B.nums/sum.b) %>%
setNames(c("B.nums", "prob.b")) %>%
summarise(sum(prob.b))
outcome.c <- C %>%
mutate(prob.c <- C.nums/sum.c) %>%
setNames(c("C.nums", "prob.c")) %>%
summarise(sum(prob.c))
paste("The sum of probabilities of the outcome is: ", "For B:", outcome.b[1,1], "and For C:", outcome.c[1,1])
## [1] "The sum of probabilities of the outcome is: For B: 1 and For C: 1"
By satisfying both conditions, It has proven that B and C have proper probabilities.
P.a <- sum((B.nums+C.nums) < 1/2)/length(B.nums)
P.a
## [1] 0.1226
P.b <- sum((B.nums*C.nums) < 1/2)/length(B.nums)
P.b
## [1] 0.8485
P.c <- sum(abs((B.nums-C.nums)) < 1/2)/length(B.nums)
P.c
## [1] 0.7478
P.d <- sum(pmax(B, C) < 1/2)/nrow(B)
P.d
## [1] 0.2506
P.e <- sum(pmin(B, C) < 1/2)/nrow(B)
P.e
## [1] 0.7553