Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zconfidence_interval = function(n, sample_mean, alfa, deviation)
- {
- sigma = sqrt(deviation);
- critical_z= qnorm(1-alfa/2,0,1);
- a= sample_mean-critical_z*sigma/sqrt(n);
- b = sample_mean+critical_z*sigma/sqrt(n);
- interval = c(a,b);
- return(interval)
- }
- #print(zconfidence_interval(8, 140,0.05,100))
- test_proportion = function(n, alfa, succeses, p0, type)
- {
- p_prim = succeses/n;
- if(type == 0)
- {critical_z=qnorm(alfa,0,1);}
- else {
- if(type == 1)
- {critical_z=qnorm(1-alfa,0,1);}
- else
- {if (type==2)
- critical_z=qnorm(1-alfa/2,0,1);
- }
- }
- z_score=(p_prim- p0)/sqrt(p0*(1-p0)/n);
- if(p_prim<p0 && z_score<critical_z)
- return ("First statement is false");
- if(p_prim>p0 && z_score> critical_z)
- return("First statement is false");
- if(p_prim != p0 && abs(z_score) > abs(critical_z))
- return("First statement is false");
- return ("First statement is true");
- }
- print(test_proportion(100, 0.01,48,0.509,0))
- print(test_proportion(100, 0.05,48,0.509,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement