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.
# Set seed v alue
set.seed(1)
n <- 1000000
# Generate two sereis of random variables B and C
B <- runif(n,0,1)
C <- runif(n,0,1)
# See first few values
head(B)
## [1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819 0.8983897
head(C)
## [1] 0.14011775 0.69562066 0.72888445 0.09164734 0.06661200 0.61285721
To prove proper probability distributions we’ve to show that all all the values are greater than 0 and the empirical cumulative values lies between 0 to 1. Here all the values of variable B and C are greater than 0.
ecdf(B)
## Empirical CDF
## Call: ecdf(B)
## x[1:999880] = 1.5483e-07, 5.2433e-07, 1.0892e-06, ..., 1, 1
ecdf(C)
## Empirical CDF
## Call: ecdf(C)
## x[1:999865] = 1.099e-07, 9.5111e-07, 1.522e-06, ..., 1, 1
From the empirical cumulitive distribution we can see that the value of cumulutive distrubiotn functions for both B and C lies between 0 to 1 that is the total probability is 1.
From the above discussion we can say that randomly choosen two random numbers B and C are proper probabilijty distributions.
Find the probability that (a) B + C < 1/2.
Answer:
We find the sum of the proabilities of each B + C < 0.5.
sum(punif((B+C)<0.5, min=0, max=1)) / n
## [1] 0.125325
The probability that the the sum of B and C values falls below \(\frac{1}{2}\) is 0.125325. (b) BC < 1/2.
Answer:
We find the sum of the proabilities of each B * C < 0.5.
sum(punif((B*C)<0.5, min=0, max=1)) / n
## [1] 0.846724
The probability that the the product of B and C values falls below \(\frac{1}{2}\) is 0.846724.
Answer:
We find the sum of the proabilities of each |B â C| < 1/2.
sum(punif(abs(B-C)<0.5, min=0, max=1)) / n
## [1] 0.7502
The probability that the the absolute difference of B and C values falls below \(\frac{1}{2}\) is 0.7502.
Answer: We find the sum of the proabilities of each max{B,C} < 1/2.
favor <- 0
for(i in 1:length(B)){
if(max(B[i], C[i]) < 0.5){
favor <- favor + 1
}
}
favor/n
## [1] 0.250287
The probability that the maximum value of B and C falls below \(\frac{1}{2}\) is 0.250287.
favor <- 0
for(i in 1:length(B)){
if(min(B[i], C[i]) < 0.5){
favor <- favor + 1
}
}
favor/n
## [1] 0.749991
The probability that the minimum value of B and C falls below \(\frac{1}{2}\) is 0.749991.