4.1

(c) Contour Plot

Plot \(Distance^2 < \chi_2^2(.50)=1.39\): \[f(\textbf x) = \frac{1}{2 \pi det(\Sigma)^{(1/2)}} e^{- \chi_2^2(.50)/2 }\]

library(ellipse)
library(latex2exp)
# mu <- c(1, 3)
# sigma <- matrix(c(2, -0.8*sqrt(2), -0.8*sqrt(2), 1), 2)
# mixtools::ellipse(mu, sigma, npoints = 1000, newplot = TRUE, alpha = 0.5,
#     pch = 16, cex = .1, xlab = TeX("x_1"), ylab = TeX("x_2"),
#     main="50% Contour Plot")

# ellipse::ellipse(corr, std(vector), centre = mu(vector), level = 0.5, npoints= 1000)
ell_data <- ellipse(-0.8, c(sqrt(2),1), centre = c(1,3), level = 0.5, npoints= 1000)
ggplot(as.data.frame(ell_data))+
    geom_point(aes(x=x, y=y),size = 0.1, color="#F8766D")+
    labs(x=TeX("$x_1$"), 
        y=TeX("$x_2$"), 
        title="50% Contour Plot") + theme+
    theme(axis.text.x = element_text(size = 7, face = "plain", angle = 0))