DATA 605 FUNDAMENTALS OF COMPUTATIONAL MATHEMATICS

Assignment 5

Kyle Gilde

10/1/2017

##           installed_and_loaded.packages.
## prettydoc                           TRUE
## stats                               TRUE
## rmutil                              TRUE

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

  1. B + C < 1/2.
# the integral of the function = 1
fab <- function(a, b) {
    (dunif(a) + dunif(b))
}
upper_bound <- 0.5
lower_bound <- 0
(Fab <- int2(fab, c(lower_bound, lower_bound), c(upper_bound, upper_bound)))
## [1] 0.5
Fab == 1
## [1] FALSE
# non-negativity
x <- runif(1000)
df <- expand.grid(x, x)
min(fab(df$Var1, df$Var2)) > 0
## [1] TRUE
# probability
set.seed(0.6)
B <- runif(1e+05)
C <- runif(1e+05)

sum(B + C < 0.5)/length(B)
## [1] 0.12412
  1. BC < 1/2.
# the integral of the function = 1
fab <- function(a, b) {
    (dunif(a) * dunif(b))
}
upper_bound <- 1
lower_bound <- 0
(Fab <- int2(fab, c(lower_bound, lower_bound), c(upper_bound, upper_bound)))
## [1] 1
Fab == 1
## [1] TRUE
# non-negativity
x <- runif(1000)
df <- expand.grid(x, x)
min(fab(df$Var1, df$Var2)) > 0
## [1] TRUE
# probability
set.seed(0.6)
B <- runif(1e+05)
C <- runif(1e+05)

sum(B * C < 0.5)/length(B)
## [1] 0.84857
  1. |B − C| < 1/2.
# the integral of the function = 1
fab <- function(a, b) {
    abs(dunif(a) - dunif(b))
}
upper_bound <- 1
lower_bound <- 0
(Fab <- int2(fab, c(lower_bound, lower_bound), c(upper_bound, upper_bound)))
## [1] 0
Fab == 1
## [1] FALSE
# non-negativity
x <- runif(1000)
df <- expand.grid(x, x)
min(fab(df$Var1, df$Var2)) > 0
## [1] FALSE
# probability
set.seed(0.6)
B <- runif(1e+05)
C <- runif(1e+05)

sum(abs(B - C) < 0.5)/length(B)
## [1] 0.74771
  1. max{B,C} < 1/2.
# the integral of the function = 1
fab <- function(a, b) {
    max(dunif(a), dunif(b))
}
upper_bound <- 1
lower_bound <- 0
(Fab <- int2(fab, c(lower_bound, lower_bound), c(upper_bound, upper_bound)))
## [1] 1
Fab == 1
## [1] TRUE
# non-negativity
x <- runif(1000)
df <- expand.grid(x, x)
min(fab(df$Var1, df$Var2)) > 0
## [1] TRUE
# probability
set.seed(0.6)
B <- runif(1e+05)
C <- runif(1e+05)

sum(pmax(B, C) < 0.5)/length(B)
## [1] 0.24749
  1. min{B,C} < 1/2.
# the integral of the function = 1
fab <- function(a, b) {
    min(dunif(a), dunif(b))
}
upper_bound <- 1
lower_bound <- 0
(Fab <- int2(fab, c(lower_bound, lower_bound), c(upper_bound, upper_bound)))
## [1] 1
Fab == 1
## [1] TRUE
# non-negativity
x <- runif(1000)
df <- expand.grid(x, x)
min(fab(df$Var1, df$Var2)) > 0
## [1] TRUE
# probability
set.seed(0.6)
B <- runif(1e+05)
C <- runif(1e+05)

sum(pmin(B, C) < 0.5)/length(B)
## [1] 0.75025