Page 183 Exercise 7

7 Let x and y be chosen at random from the interval [0,1]. Show that the events x > 1/3 and y > 2/3 are independent events. Genearete x and y

# Set seed value
set.seed(1)
# Size of sample
n <- 100000
# Generate x and y
x <- runif(n,0,1)
y <- runif(n,0,1)

Probability of x

prob_x <- sum(punif(x>1/3, min=0, max=1)) / n
prob_x
## [1] 0.66602

Probability of y

prob_y <- sum(punif(y>2/3, min=0, max=1)) / n
prob_y
## [1] 0.33332

Probability of x and y occuring together

prob_xy <- sum(punif(x>1/3 & y > 2/3, min=0, max=1)) / n
prob_xy
## [1] 0.22094

For showing x > 1/3 and y > 2/3 are independent events we’ve to show that p(x and y) = p(x)*p(y)

prob_x*prob_y
## [1] 0.2219978

Here p(x and y) = 0.22094 and p(x)*p(y) = 0.2219978 is approximately equal . From this we can say that x > 1/3 and y > 2/3 are independent events.