Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I.1
- z_test=function(alfa,p_mean,s_mean,n,sigma, ipoteza)
- {
- z_score = (s_mean - p_mean)/(sigma/sqrt(n))
- if(ipoteza == 1) {
- critical_z = qnorm(alfa)
- }
- if(ipoteza == 2) {
- critical_z = qnorm(1 - alfa)
- }
- if(ipoteza == 3) {
- critical_z = qnorm(1 - alfa/2)
- }
- if(ipoteza == 1) {
- if(z_score > critical_z) {
- print("H0 respinsa")
- }
- else {
- print("Nu se poate calcula")
- }
- }
- if(ipoteza == 2) {
- if(z_score > critical_z) {
- print("H0 respinsa")
- }
- else {
- print("Nu se poate calcula")
- }
- }
- if(ipoteza == 3) {
- if(abs(z_score) > abs(critical_z)) {
- print("H0 respinsa")
- }
- else {
- print("Nu se poate calcula")
- }
- }
- print(z_score)
- print(critical_z)
- }
- I.2
- z_test(0.01, 90, 90, 49, sqrt(144), 1)
- I.3
- z_test(0.01, 75, 85, 36, sqrt(17), 3)
- I.4
- z_test(0.01, 21, 20.5, 100, 2.5, 2)
- I.5
- z_test(0.05, 1000, 970, 100, 85, 1)
- z_test(0.01, 1000, 970, 100, 85, 1)
- I.6
- z_test(0.01, 22, 20, 16, 3, 3)
- II.1
- t_test=function(filename,alfa,p_mean)
- {
- a=citire(filename)
- b=calcul(a);n=b[1]
- s_mean=b[2]
- sigma=b[3]
- if(p_mean>s_mean)
- {
- critical_t = qt(alfa,n-1)
- t_score = (s_mean - p_mean)/(sigma/sqrt(n))
- }
- else
- {
- critical_t = qt(1- alfa,n-1)
- t_score = (s_mean - p_mean)/(sigma/sqrt(n))
- }
- if(t_score>critical_t)
- {
- cat("H0 respinsa")
- }
- else
- {
- cat("H0 acceptata")
- }
- cat("\n")
- print(t_score)
- print(critical_t)
- }
- calcul=function(a)
- {
- n=length(a)
- media=mean(a)
- s=sd(a)
- b<-c(n,media,s)
- }
- citire=function(fisier)
- {
- a<-scan(fisier)
- }
- II.2
- t_test("vector.txt",0.01,34)
- II.3
- z_test(0.01,11.4,11.9,100,0.25)
- z_test(0.05,11.4,11.9,100,0.25)
- II.4
- t_test("sample1.txt",0.01,80)
- t_test("sample1.txt",0.05,80)
- II.5
- z_test(0.01,49,52,64,sqrt(89.5))
- II.6
- z_test(0.05,30,29,40,sqrt(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement