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.

As per definition 2.1 both \(B\) and \(C\) are continuous real-valued random variables as each one can take any of an uncountably infinite number of values between 0 and 1 inclusive. In this example \(P(0 \leq B \leq 1) = 1\) and \(P(0 \leq C \leq 1) = 1\). Since the summation of all the possible results of the continuous random variable is 1, \(B\) and \(C\) are each probaiblity distributions.

For each continuous random variable, a density function can be defined as:

\(P(0 \leq B \leq 1) = \int_{0}^{1} f(x)dx\) and \(P(0 \leq C \leq 1) = \int_{0}^{1} f(x)dx\)

In this problem, we can represent the distributions by plotting the point \((B, C)\) in the unit square. The area of the resulting figure is the probability of the corresponding event.

Find the following probabilities:

ggplot() +
  geom_abline(aes(slope=-1, intercept=.5)) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 0), y=c(0, 0, 0.5)), aes(x, y), fill='blue', alpha=0.2) +
  scale_x_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0)) +
  scale_y_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0))

This shape is a triangle and it’s area can be calculated as: \(\frac{1}{2} \times 0.5 \times 0.5 = 0.125\) Thus \(P(B + C) < \frac{1}{2} = 0.125 = 12.5\%\)

valid <- 0
for(i in 1:500000){
  if(sum(runif(2, min=0, max=1)) < 0.5){
    valid <- valid + 1
  }
}
print(valid / 500000)
## [1] 0.124938
test <- function(x) {0.5 * x^-1}
ggplot(data.frame(x=c(0, 2)), aes(x)) +
  stat_function(fun=test) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 0.5, 0), y=c(0, 0, 1, 1)), aes(x, y), fill='blue', alpha=0.2) +
  stat_function(fun=test, xlim=c(0, 1), geom='area', fill='blue', alpha=0.2) +
  scale_x_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0)) +
  scale_y_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0))

The area of this shape can be broken down into two compontents. The first has a domain from 0 to 0.5 and is a rectangle with area 0.5. The second is the area under the curve \(\frac{1}{2x}\) and can be found by calculating the definite integral \(\int_{0.5}^{1}\frac{1}{2x}dx = \frac{log(x)}{2}\bigg\rvert_{0.5}^{1} = \frac{log(1)}{2} - \frac{log(0.5)}{2} = 0.346574\)

Finally, \(0.5 + 0.346574 = 0.846574\)

Thus \(P(B \times C) < \frac{1}{2} = 0.846574\)

valid <- 0
for(i in 1:500000){
  if(prod(runif(2, min=0, max=1)) < 0.5){
    valid <- valid + 1
  }
}
print(valid / 500000)
## [1] 0.846774
ggplot() +
  geom_abline(aes(slope=1, intercept=.5)) +
  geom_abline(aes(slope=1, intercept=-.5)) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 1, 1, 0.5, 0), y=c(0, 0, 0.5, 1, 1, 0.5)), aes(x, y), fill='blue', alpha=0.2) +
  scale_x_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0)) +
  scale_y_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0))

The area between these two lines can be more easily found by calculating the upper and lower triangles and subracting them away from 1. The area of each of the triangles is \(\frac{1}{2}\times 0.5 \times 0.5 = 0.125\) Therefore \(1 - 0.125 - 0.125 = 0.75\)

\(P(\mid B - C \mid < \frac{1}{2}) = 0.75\)

valid <- 0
for(i in 1:500000){
  if(abs(diff(runif(2, min=0, max=1))) < 0.5){
    valid <- valid + 1
  }
}
print(valid / 500000)
## [1] 0.74877
ggplot() +
  geom_abline(aes(slope=1, intercept=0)) +
  geom_hline(yintercept=0.5) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 0), y=c(0, 0.5, 0.5)), aes(x, y), fill='blue', alpha=0.2) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 0.5), y=c(0, 0.5, 0)), aes(x, y), fill='red', alpha=0.2) +
  geom_vline(xintercept=0.5) +
  scale_x_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0)) +
  scale_y_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0))

The area in the bottom left, beneath the vertical line and to the left of the horizontal line can easily be found as it is a square. \(0.5 \times 0.5 = 0.25\)

\(P(max\{B, C\} < \frac{1}{2}) = 0.25\)

valid <- 0
for(i in 1:500000){
  if(max(runif(2, min=0, max=1)) < 0.5){
    valid <- valid + 1
  }
}
print(valid / 500000)
## [1] 0.250458
ggplot() +
  geom_hline(yintercept=0.5) +
  geom_polygon(data=data.frame(x=c(0, 0.5, 0.5, 0), y=c(0, 0, 1, 1)), aes(x, y), fill='red', alpha=0.2) +
  geom_polygon(data=data.frame(x=c(0, 1, 1, 0), y=c(0, 0, 0.5, 0.5)), aes(x, y), fill='blue', alpha=0.2) +
  geom_vline(xintercept=0.5) +
  scale_x_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0)) +
  scale_y_continuous(limits=c(0, 1), expand=c(0, 0, 0, 0))

The area to the left of the vertical line OR benearth the horizontal line can be easily found as it is comprised of three equal squares. \(3(0.5 \times 0.5) = 0.75\)

\(P(min\{B, C\} < \frac{1}{2}) = 0.75\)

valid <- 0
for(i in 1:500000){
  if(min(runif(2, min=0, max=1)) < 0.5){
    valid <- valid + 1
  }
}
print(valid / 500000)
## [1] 0.75038