library(distionary)
# One is always more extreme than the other in this case.
d1 <- dst_unif(-1, 2)
d2 <- dst_unif(5, 6)
maximize(d1, d2) # d2
minimize(d1, d2) # d1
# Visualizing the maximum and minimum
d3 <- dst_norm(4, 1)
d4 <- dst_exp(0.3)
dmax <- maximize(d3, d4, draws = 1:2)
dmin <- minimize(d3, d4, draws = 1:2)
# Maximum
plot(d3, col = "blue", lty = 2, from = 0, to = 14)
plot(d4, col = "red", lty = 2, add = TRUE)
plot(dmax, add = TRUE, n = 1000)
legend(
"topright",
legend = c("Maximum", "N(4,1)", "Exp(0.3)"),
col = c("black", "blue", "red"),
lty = c(1, 2, 2)
)
# Minimum
plot(d3, col = "blue", lty = 2, from = 0, to = 10)
plot(d4, col = "red", lty = 2, add = TRUE)
plot(dmin, add = TRUE, n = 1000)
legend(
"topright",
legend = c("Minimum", "N(4,1)", "Exp(0.3)"),
col = c("black", "blue", "red"),
lty = c(1, 2, 2)
)
Run the code above in your browser using DataLab