y = c(576, 635, 558, 578, 666, 580, 555, 661, 651, 605, 653, 575, 545, 572, 594)
z = c(3.39, 3.30, 2.81, 3.03, 3.44, 3.07, 3.00, 3.43, 3.36, 3.13, 3.12, 2.74, 2.76, 2.88, 3.96)
n = length(y)

# uzoracki koeficijent korelacije
(Tn = cor(y, z))

# Dzeknajf ocena standardne greske 
T_i = rep(0, n)
for (i in 1:n) {
  T_i[i] = cor(y[-i], z[-i])
}
(se_jack = sqrt( (n - 1)^2 / n * var(T_i) ))
    

# Butstrep ocena standardne greske 
B = 1000
T_B = c()
for (i in 1:B) {
  indeks = sample(1:n, n, replace = T)
  T_B[i] = cor(y[indeks], z[indeks])
}
(se_B = sqrt( (B - 1) / B * var(T_B) ))
