Assignment Week 5

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 that

#Create the variables b and c, using the function runif
#runif will run 1000, and not reach the min or max 
b <- runif(1000, min = 0, max = 1)
c <- runif(1000, min = 0, max = 1)

#Let's use historgrams to check the distributions of the b and c variables, both are about evenly distributed
hist(b)

hist(c)

  1. B + C < 1/2
#Sum gives the total number of values that meet the condition, in this case values below 0.5
ans_A <- sum(b + c < 0.5)

#Divide by 1000 to calculate the probability
ans_A <- ans_A/1000

paste("The probability is", ans_A)
## [1] "The probability is 0.126"
  1. BC < 1/2
ans_B <- sum(b*c < 0.5)/1000
paste("The probability is", ans_B)
## [1] "The probability is 0.833"
  1. |B − C| < 1/2
ans_C <- sum(abs(b-c) < 0.5)/1000
paste("The probability is", ans_C)
## [1] "The probability is 0.767"
  1. max{B,C} < 1/2
#Used Max function and the answer was .001, so used the pmax and pmin functions
ans_D <- sum(pmax(b,c) < 0.5)/1000
paste("The probability is", ans_D)
## [1] "The probability is 0.239"
  1. min{B,C} < 1/2
ans_E <- sum(pmin(b,c) < 0.5)/1000
paste("The probability is", ans_E)
## [1] "The probability is 0.725"