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.
The probability density function (PDF) of X is the function \(f_{x}(x)\) such that for any two number a and b in the domain \(X\), with a
For both B and C, \(f_{x}(X)\geq 0\)for all values within [0,1] and \(\int f_{X}(x)dx=1\).
The following values assigned to b and c are for simulations:
b <- runif(n = 1000000,0,1)
c <- runif(n = 1000000,0,1)
hist(b)
hist(c)
Note that the point (B,C) is then chosen at random in the unit squre. Find the probability that
(a) B + C < \(\frac{1}{2}\)
\(P(x,y)=\int_{a}^{b}\int_{a}^{b}\space f(x,y)\space dy\space dx\)
\(f(x,y)=x+y\space dy\space dx\) \(P(x,y)=\int_{0}^{\frac{1}{2}}\int_{0}^{\frac{1}{2}}\space x+y\space dy\space dx\)
library(pracma)
f1 <- function(x,y){x+y}
integral2(f1,0,1/2,0,1/2)$Q
## [1] 0.125
x1 <- seq(0,1,0.01)
y1 <- function(x){1/2-x}
curve(y1,0,1,ylim=c(0,1),lwd=0.2)
Based on the graph, we can compute \(A=(\frac{1}{2})(\frac{1}{2})(\frac{1}{2})=\frac{1}{8}\)
calculated using simulation:
total1 <- 0
for (i in 1:length(b)) {
if (b[i]+c[i] < 1/2) {
total1 <- total1 + 1
}
}
p1 <- total1 / length(b)
p1
## [1] 0.125022
x2 <- seq(0,1,0.01)
y2 <- function(x){1/2/x}
curve(y2,0,1,ylim=c(0,1),lwd=0.2)
calculated using simulation:
total2 <- 0
for (i in 1:length(b)) {
if (b[i]*c[i] < 1/2) {
total2 <- total2 + 1
}
}
p2 <- total2 / length(b)
p2
## [1] 0.846309
f3_a <- function(x){x+1/2}
f3_b <- function(x){x-1/2}
int <- integral(f3_a,0,1/2)+(1/2)*1-integral(f3_b,1/2,1)
int
## [1] 0.75
By simulation:
total3 <- 0
for (i in 1:length(b)) {
if (abs(b[i]-c[i]) < 1/2) {
total3 <- total3 + 1
}
}
p3 <- total3 / length(b)
p3
## [1] 0.750408
For B > C, max{B,C}=B, B\(\in[0,\frac{1}{2}]\), C\(\in[0,\frac{1}{2}]\).
similarly for C > B.
\(\therefore\) B\(\in[0,\frac{1}{2}]\) and C\(\in[0,\frac{1}{2}]\).
P(max{b,C}<\(\frac{1}{2}\))=\((\frac{1}{2})(\frac{1}{2})=\frac{1}{4}\)
total4 <- 0
for (i in 1:length(b)) {
if (max(b[i],c[i]) < 1/2) {
total4 <- total4 + 1
}
}
p4 <- total4 / length(b)
p4
## [1] 0.24979
For B > C, min{B,C} = C, C\(\in[0,\frac{1}{2}]\), C\(\in[\frac{1}{2},1]\).
similarly for C > B.
\(\therefore\) when C\(\in[0,\frac{1}{2}]\),B\(\in[\frac{1}{2},1]\) and when B\(\in[0,\frac{1}{2}]\),C\(\in[\frac{1}{2},1]\).
P(min{b,C}<\(\frac{1}{2}\))=\([(1)(\frac{1}{2})+(1)(\frac{1}{2})-(\frac{1}{2})(\frac{1}{2})]=\frac{3}{4}\)
total5 <- 0
for (i in 1:length(b)) {
if (min(b[i],c[i]) < 1/2) {
total5 <- total5 + 1
}
}
p5 <- total5 / length(b)
p5
## [1] 0.749517