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
Using runif function in R to choose random numbers from a uniform distribution in the interval [0, 1]
B <- runif(10000, min = 0, max = 1)
C <- runif(10000, min = 0, max = 1)
hist(B);
hist(C)
First step is to create a histogram of B+C to show that although the they have uniform distribution individually, their sum may not a uniform distribution.
X <- B+C
hist(X, main = "distribution of B+C")
# The probability that B+C < 1/2
a <- sum(X < .5)/10000
a
## [1] 0.1268
We can see the the distribution for BC is right skewed.
X <- B*C
hist(X, main = "distribution of BC")
# the probability of BC < 1/2
b <- sum(X < .5)/10000
b
## [1] 0.8433
Lets look at the distribution of absolute value of the difference between B and C.
X <- abs(B-C)
hist(X, main = "distribution of |B-C|")
# the probability of |B-C| < 1/2
c <- sum(X < .5)/10000
c
## [1] 0.7575
We can use the same simulation to find the probability of max of B and C is less than 1/2
X <- pmax(B,C)
hist(X, main = "distribution of max{B,C}")
# the probability of max{B,C} < 1/2
d <- sum(X < .5)/10000
d
## [1] 0.2555
At last we can use the same simulation to find the probability of min of B and C is less than 1/2
X <- pmin(B,C)
hist(X, main = "distribution of min{B,C}")
# the probability of min{B,C} < 1/2
e <- sum(X < .5)/10000
e
## [1] 0.749