Warning: package 'tidyverse' was built under R version 4.3.3
Warning: package 'tibble' was built under R version 4.3.3
Warning: package 'tidyr' was built under R version 4.3.3
Warning: package 'readr' was built under R version 4.3.3
Warning: package 'purrr' was built under R version 4.3.3
Warning: package 'dplyr' was built under R version 4.3.3
Warning: package 'stringr' was built under R version 4.3.3
Warning: package 'forcats' was built under R version 4.3.3
Warning: package 'lubridate' was built under R version 4.3.3
ββ Attaching core tidyverse packages ββββββββββββββββββββββββ tidyverse 2.0.0 ββ
β dplyr 1.1.4 β readr 2.1.5
β forcats 1.0.0 β stringr 1.5.1
β ggplot2 4.0.1 β tibble 3.2.1
β lubridate 1.9.4 β tidyr 1.3.1
β purrr 1.0.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
Attaching package: 'purrrfect'
The following objects are masked from 'package:base':
replicate, tabulate
Practice Set 7.3
Creating the Dataset
df <-(parameters(~i,~n,~lambda,c(3,5,9),c(10,15,20),c(.05,.1))
%>%add_trials(10000)
%>%mutate(Y = pmap(list(n,lambda),\(x,y) sort(rexp(x,y))),Y_i = pmap_dbl(list(i,Y),\(x,y) pluck(y,x)),Y_i_1 = pmap_dbl(list(i,Y),\(x,y) pluck(y,x-1)),T_s=pmap_dbl(list(Y_i,Y_i_1),\(x,y) x-y),ft = pmap_dbl(list(T_s,i,n,lambda),\(x,y,z,w) dexp(x,w*(z-y+1))))
)
Plotting all combinations
(ggplot(data = df)
+ geom_histogram(aes(x = T_s,y = after_stat(density)), fill = "gold",binwidth = .05,center = .01)
+ geom_line(aes(x=T_s,y=ft),color = "blue")
+ facet_grid(~i~n~lambda,labeller =label_both,scales = "free")
+ theme_classic()
+ labs(title = "Y1")
+ scale_x_continuous(limits = c(0, 4))
)
Warning: Removed 24313 rows containing non-finite outside the scale range
(`stat_bin()`).
Warning: Removed 36 rows containing missing values or values outside the scale range
(`geom_bar()`).
Warning: Removed 24313 rows containing missing values or values outside the scale range
(`geom_line()`).