set.seed(2023)
x<-rnorm(120,3,0.6)
cat("CV:",sd(x)/mean(x)*100)
## CV: 19.61552
hist(x)

shapiro.test(x)
## 
##  Shapiro-Wilk normality test
## 
## data:  x
## W = 0.98922, p-value = 0.4671
nortest::ad.test(x)
## 
##  Anderson-Darling normality test
## 
## data:  x
## A = 0.26763, p-value = 0.68
nortest::cvm.test(x)
## 
##  Cramer-von Mises normality test
## 
## data:  x
## W = 0.031606, p-value = 0.8229
nortest::lillie.test(x)
## 
##  Lilliefors (Kolmogorov-Smirnov) normality test
## 
## data:  x
## D = 0.039379, p-value = 0.9197
nortest::sf.test(x)
## 
##  Shapiro-Francia normality test
## 
## data:  x
## W = 0.99119, p-value = 0.5553
set.seed(123)
y<-rexp(n = 120,rate = 1/mean(x))
mean(y)
## [1] 3.018727
cat("CV:",sd(y)/mean(y)*100)
## CV: 99.72399
cv_fun=function(x){
  cv_formula = sd(x)/mean(x)*100
  SE_cv=cv_formula/(sqrt(2*length(x)))
  SE_cv_c=(cv_formula*(1+1/(4*length(x))))/(sqrt(2*length(x)))
  return(list(cv_formula=cv_formula,SE_cv=SE_cv,SE_cv_c=SE_cv_c))
}
cv_fun(x)
## $cv_formula
## [1] 19.61552
## 
## $SE_cv
## [1] 1.266176
## 
## $SE_cv_c
## [1] 1.268814
set.seed(2023)
sim1=replicate(n = 1000,expr = rnorm(120,3,0.6))

CV_sim=apply(sim1,2,function(.){cv_fun(.)$cv_formula})
plot(CV_sim)

SE =sd(CV_sim)
library(ggplot2)

CV_sim=data.frame(CV_sim=CV_sim)

ggplot(CV_sim,aes(x=CV_sim))+
  geom_histogram()+
  geom_vline(xintercept = quantile(CV_sim$CV_sim,c(0.025,0.975)))+
  geom_vline(xintercept = mean(CV_sim$CV_sim),col="red")+
  geom_vline(xintercept = quantile(CV_sim$CV_sim,c(0.95)),col="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Performance <- matrix(c(6, 8, 1, 5),
       nrow = 2,
       dimnames = list("Datos" = c("Positivo", "Negativo"),"Algoritmo" = c("Positivo", "Negativo")))

Simular los datos de la tabla, con n=20 Cuantas tabla 2x2 diferentes se pueden construir con 20 datos