Q :- Prove that B and C are proper probability distributions
# A probability distribution is a statistical function that describes all the possible values and likelihoods that a random variable can take within a given range. This range will be between the minimum and maximum statistically possible values.
n <- 10000
B <- as.data.frame(runif(n, min=0, max=1))
C <- as.data.frame(runif(n, min=0, max=1))
min(B)
## [1] 0.0001683552
max(B)
## [1] 0.9998546
# checking the skewness of B
hist(B[,1], prob=TRUE, ylim=c(0,1.5), main = 'Histogram of B', xlab = '')
min(C)
## [1] 5.254173e-05
max(C)
## [1] 0.9999642
#checking skewness of C
hist(C[,1], prob=TRUE, ylim=c(0,1.5), main = 'Histogram of B', xlab = '')
j = 0
for(i in 1:length(B)){
if(B[i]+C[i] < 0.5){
j = j+1
}
}
## Warning in if (B[i] + C[i] < 0.5) {: the condition has length > 1 and only
## the first element will be used
print(paste("The Probabilty B+C < 1/2 =", j/length(B)))
## [1] "The Probabilty B+C < 1/2 = 0"
As we can see bins of both the histogram are evenly distributed, B & C is proper probability distributions.
a <- sum((B+C) < .5)/n
print(paste("The probability of B+C less than 1/2 is",a))
## [1] "The probability of B+C less than 1/2 is 0.1244"
b <- (sum((B*C) < .5)/n)
print(paste("The probability of B*C less than 1/2 is",b))
## [1] "The probability of B*C less than 1/2 is 0.8483"
c <- sum(abs((B-C)) < .5)/n
print(paste("The probability of |B-C| be less than 1/2 is",c))
## [1] "The probability of |B-C| be less than 1/2 is 0.7362"
d <- 1
B <- runif(n, min=0, max=1)
C <- runif(n, min=0, max=1)
for(i in 1:length(B)){
if(max(B[i], C[i]) < 0.5){
d = d + 1
}
}
d <- d/10000
print(paste("The probability of max{B,C} less than 1/2 is",d))
## [1] "The probability of max{B,C} less than 1/2 is 0.253"
e <- 1
B <- runif(n, min=0, max=1)
C <- runif(n, min=0, max=1)
for(i in 1:length(B)){
if(min(B[i], C[i]) < 0.5){
e = e + 1
}
}
e <- e/10000
print(paste("The probability of min{B,C} less than 1/2 is",d))
## [1] "The probability of min{B,C} less than 1/2 is 0.253"