library(ggplot2)
f_pdf <- function(y) ifelse(y > 1, 4 / (y^5), 0)
f_cdf <- function(y) ifelse(y > 1, 1 - (1 / (y^4)), 0)
# 2 PDF
ggplot(data.frame(y = c(1, 4)), aes(x = y)) +
stat_function(fun = f_pdf, color = "darkblue", linewidth = 1) +
labs(title = "PDF: f(y) = 4/y^5", x = "y", y = "f(y)") +
theme_minimal()sim4.1
# 2 CDF
ggplot(data.frame(y = c(1, 4)), aes(x = y)) +
stat_function(fun = f_cdf, color = "firebrick", linewidth = 1) +
labs(title = "CDF: F(y) = 1 - 1/y^4", x = "y", y = "F(y)") +
theme_minimal()#3 PDF
ggplot(data.frame(x = c(-5, 5)), aes(x)) +
stat_function(fun = dcauchy, color = "darkblue", linewidth = 1) +
labs(title = "PDF", x = "y", y = "f(y)") +
theme_minimal()# 3 CDF
ggplot(data.frame(x = c(-5, 5)), aes(x)) +
stat_function(fun = pcauchy, color = "firebrick", linewidth = 1) +
labs(title = "CDF", x = "y", y = "F(y)") +
theme_minimal()