M <- 38/150 c <- 0.3 n <- 150 alpha <- 0.05 n*c*(1-c) t0 <- (M-c)/sqrt(c*(1-c)/n) t0 qnorm(alpha) HH <- M-sqrt((M*(1-M)/n))*qnorm(alpha) HH p <- pnorm(t0) p X <- c(62, 54, 55, 60, 53, 58) Y <- c(52, 56, 49, 50, 51) shapiro.test(X) shapiro.test(Y) par(mfrow=c(1,2)) qqnorm(X, xlab='Teoreticky kvantil', ylab='Vyberovy kvantil') qqline(X, col='red') qqnorm(Y, xlab='Teoreticky kvantil', ylab='Vyberovy kvantil') qqline(Y, col='blue') hist(X) hist(Y) n1 <- length(X) n2 <- length(Y) s1 <- sd(X) s2 <- sd(Y) alpha <- 0.05 t0 <- s1^2/s2^2 t0 qf(alpha/2, n1-1, n2-1) qf(1-alpha/2, n1-1, n2-1) 2*min(pf(t0, n1-1, n2-1), 1-pf(t0, n1-1, n2-1)) m1 <- mean(X) m2 <- mean(Y) n1 <- length(X) n2 <- length(Y) alpha=0.05 s1 <- sd(X) s2 <- sd(Y) s_h <- sqrt( ((n1-1)*s1^2 +(n2-1)*s2^2) / (n1+n2-2) ) s_h dh <- m1-m2-s_h*sqrt(1/n1+1/n2)*qt(1-alpha/2, n1+n2-2) dh hh <- m1-m2-s_h*sqrt(1/n1+1/n2)*qt(alpha/2, n1+n2-2) hh par(mfrow=c(1,1)) boxplot(X,Y) points(1, mean(X), col='red', pch=19) points(2, mean(Y), col='red', pch=19)