#2f
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
f.y <- function(y) {
pdf <- ifelse(y <= 1, 0, 4/y^5)
return(pdf)
}
F.y <- function(y) {
CDF <- case_when(y <= 1 ~ 0,
y > 1 ~ 1 - 1/y^4)
return(CDF)
}
(data <- data.frame(y = seq(0, 5, length = 300))
%>% mutate(f = f.y(y), F = F.y(y))
) %>% head y f F
1 0.00000000 0 0
2 0.01672241 0 0
3 0.03344482 0 0
4 0.05016722 0 0
5 0.06688963 0 0
6 0.08361204 0 0
(ggplot(data = data)
+ geom_line(aes(x = y, y = f))
+ theme_classic(base_size = 14)
)(ggplot(data = data)
+ geom_line(aes(x = y, y = F))
+ theme_classic(base_size = 14)
)