diff options
Diffstat (limited to '291/CH11/EX11.2d/eg11_2d.sce')
-rwxr-xr-x | 291/CH11/EX11.2d/eg11_2d.sce | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/291/CH11/EX11.2d/eg11_2d.sce b/291/CH11/EX11.2d/eg11_2d.sce new file mode 100755 index 000000000..4834c49e4 --- /dev/null +++ b/291/CH11/EX11.2d/eg11_2d.sce @@ -0,0 +1,22 @@ +X = [3 3 5 18 4 7];
+p= [0.1 0.1 0.05 0.4 0.2 0.15];
+psimu = 0.1843; //p-value obtained by simulation
+num= 10000;
+T= 0;
+n=sum(X);
+np = n*p;
+Xsqu = X.^2;
+for i= 1:6
+ T = T + (Xsqu(i)/np(i));
+end
+T = T - sum(X);
+
+disp(T(1), "The test statistic is")
+pvalue = 1- cdfchi("PQ",T(1), 5);
+//disp(pvalue, "The pvalue is ")
+int1 = psimu - (1.645*sqrt(psimu*(1-psimu)/num));
+int2 = psimu + (1.645*sqrt(psimu*(1-psimu)/num));
+disp("With 90% confidence p-value lies between ")
+disp(int1)
+disp("and")
+disp(int2);
\ No newline at end of file |