library (pracma)
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.
Find the probability that
#randomly select 20,000 numbers between 0 and 1
B <- runif(10000, min = 0, max = 1)
head(B)
## [1] 0.453665454 0.121073673 0.579758759 0.377592545 0.007073041 0.124133517
C <- runif(10000, min = 0, max = 1)
head(C)
## [1] 0.1008347 0.5499531 0.1789258 0.1173376 0.9022619 0.7982616
head(B+C)
## [1] 0.5545002 0.6710268 0.7586845 0.4949302 0.9093350 0.9223951
All values of B and C are between 0 and 1 and sum of the probabilites of each value in B and C will equal 1.
Determine:
\(P(B+C<\frac { 1 }{ 2 } )=P(X+Y\quad <\quad \frac { 1 }{ 2 } )\quad =\quad P\left( 0<X<\frac { 1 }{ 2 } ,\quad 0<Y<\frac { 1 }{ 2 } -x \right)\)
a <- sum((B+C) < .5)/10000
print(paste("The probability that B+C will be less than 1/2 is",a))
## [1] "The probability that B+C will be less than 1/2 is 0.1261"
The probabilty is 12.3%. For this to be true B and C must be <1/2 aprox 0.25 and C or B is \(<\frac { 1 }{ 2 } -Compliment\quad prob\). The overall probabilty is 0.25∗0.5=0.125 which is aproximately what we see in the simulation.
\(P\left( B,C<\frac { 1 }{ 2 } \right)\)
b <- (sum((B*C) < .5)/10000)
print(paste("The probability that B*C will be less than 1/2 is",b))
## [1] "The probability that B*C will be less than 1/2 is 0.8438"
The probability is aproxiamtely 85%.There’s a 50% that B and C are less than \(\frac { 1 }{ \sqrt { 2 } }\) = 0.7071, this meand that prob > \(\frac { 1 }{ \sqrt { 2 } }\) = 0.7071, which is condition for BC > 1/2, is \(\left( 1-\frac { 1 }{ \sqrt { 2 } } \right) /2=0.1464466\). The overall probability is 1-01464466=0.85355334 aprox the result of the simulation
\(P\left( \left| X-Y \right| <\frac { 1 }{ 2 } \quad |\quad 0<\quad x+y<1 \right) =P\left( \frac { -1 }{ 2 } <X-Y<\frac { 1 }{ 2 } ;\quad 0<X<1-Y \right)\)
c <- sum(abs((B-C)) < .5)/10000
print(paste("The probability that |B-C| will be less than 1/2 is",c))
## [1] "The probability that |B-C| will be less than 1/2 is 0.7488"
For |B−C|<1/2, then B or C must be (.75,0.5), and C or B (0.5,0.25). This accounts for 1/2 of the cases where one random variable is <1/2 and the other is <1/2. This means the probabilty for the remaining cases is 1/2∗1/2=1/4=0.25. Such that 0.5+0.25=0.75, which is aproximately the result of the simulation.
\(P\left( max(B,C)<\frac { 1 }{ 2 } \right) =P\left( B<=\frac { 1 }{ 2 } ,C<=\frac { 1 }{ 2 } \right)\)
x <- 0
for(i in 1:10000){
if(max(c(B[i],C[i])) < 0.5){
x = x+1
}
}
d <- x/10000
print(paste("The probability that max{B,C} will be less than 1/2 is",d))
## [1] "The probability that max{B,C} will be less than 1/2 is 0.2519"
\(P\left( min(B,C)<=\frac { 1 }{ 2 } \right) =1-P\left( B>\frac { 1 }{ 2 } ,C>\frac { 1 }{ 2 } \right)\)
x <- 0
for(i in 1:10000){
if(min(c(B[i],C[i])) < 0.5){
x = x+1
}
}
e <- x/10000
print(paste("The probability that min{B,C} will be less than 1/2 is",e))
## [1] "The probability that min{B,C} will be less than 1/2 is 0.7516"