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.
First, we will define our interval values and simulate the draw of \(B\) and \(C\) from a uniform distriubution 10,000 times.
set.seed(123)
# Set number of runs to 10,000
n <- 10000
minVal <- 0
maxVal <- 1
setB <- runif(n, min = minVal, max = maxVal)
setC <- runif(n, min = minVal, max = maxVal)
To prove that \(B\) and \(C\) are proper probability distributions, let’s first make sure that all values are within the interval range [0,1].
# check to see if any values are below 0
paste0('Percent of times B is in correct range: ',100*length(setB[which(setB >0 & setB < 1)])/n)
## [1] "Percent of times B is in correct range: 100"
paste0('Percent of times C is in correct range: ',100*length(setC[which(setC >0 & setC < 1)])/n)
## [1] "Percent of times C is in correct range: 100"
Next, we will visually examine the distributions of \(B\) and \(C\) against a proper uniform distribution:
hist(setB,
freq = FALSE,
xlab = 'B',
density = 20,
main = "Distribution of B")
curve(dunif(x, min = minVal, max = maxVal),
from =-0.50, to = 1.5,
n = n,
col = "darkblue",
lwd = 2,
add = TRUE,
yaxt = "n",
ylab = 'probability')
hist(setC,
freq = FALSE,
xlab = 'B',
density = 20,
main = "Distribution of C")
curve(dunif(x, min = minVal, max = maxVal),
from =-0.50, to = 1.5,
n = n,
col = "darkblue",
lwd = 2,
add = TRUE,
yaxt = "n",
ylab = 'probability')
Both are nearly uniform distributions, so we can say that \(B\) and \(C\) follow proper probability distributions.
Find the probability that:
sum((setB + setC)< 0.5)/n
## [1] 0.1217
sum((setB * setC)< 0.5)/n
## [1] 0.8562
sum(abs((setB - setC))< 0.5)/n
## [1] 0.747
finalCount <- 0
for(i in seq(n)){
finalCount <- finalCount +(max(setB[i],setC[i]) < 0.5)
}
finalCount/n
## [1] 0.2558
finalCount <- 0
for(i in seq(n)){
finalCount <- finalCount +(min(setB[i],setC[i]) < 0.5)
}
finalCount/n
## [1] 0.7597