diff options
Diffstat (limited to '291')
205 files changed, 2526 insertions, 0 deletions
diff --git a/291/CH10/EX10.3a/eg10_3a.sce b/291/CH10/EX10.3a/eg10_3a.sce new file mode 100755 index 000000000..fd4239eb9 --- /dev/null +++ b/291/CH10/EX10.3a/eg10_3a.sce @@ -0,0 +1,30 @@ +Xij = [220 251 226 246 260; 244 235 232 242 225; 252 272 250 238 256];
+Xi = zeros(3,1);
+n= 5;
+m=3;
+for i=1:3
+ for j=1:5
+ Xi(i)= Xi(i) + Xij(i,j);
+ end
+end
+Xi = Xi/n;
+SSW= 0;
+for i=1:3
+ for j= 1:5
+ SSW = SSW + ((Xij(i,j)-Xi(i))^2)
+ end
+end
+sigma1 = SSW/((n*m)-m);
+Xdotdot = sum(Xi)/m;
+new = (Xi - Xdotdot)^2;
+SSb= n*sum(new);
+sigma2 = SSb/(m-1);
+TS = sigma2/sigma1;
+//disp(sigma1);
+//disp(sigma2);
+disp(TS, "Value of the test statistic is");
+pvalue = 1 - cdff("PQ", TS,m-1, ((n*m)-m) );
+disp(pvalue, "The p-value is")
+if(pvalue>0.05)
+disp( "Since the p-value is greater than .05, the null hypothesis that the mean mileage is the same for all 3 brands of gasoline cannot be rejected. ")
+end
\ No newline at end of file diff --git a/291/CH10/EX10.3b/eg10_3b.sce b/291/CH10/EX10.3b/eg10_3b.sce new file mode 100755 index 000000000..0fb2d2eed --- /dev/null +++ b/291/CH10/EX10.3b/eg10_3b.sce @@ -0,0 +1,23 @@ +Xijold = [220 251 226 246 260; 244 235 232 242 225; 252 272 250 238 256];
+Xij = Xijold - 220;
+m=3;
+n=5;
+Xidot = zeros(3,1);
+for i=1:m
+ for j=1:n
+ Xidot(i)=Xidot(i) + Xij(i,j);
+ end
+end
+Xidot = Xidot/n;
+Xdotdot = sum(Xidot)/m;
+SSb=0;
+for i=1:m
+ SSb = SSb + (Xidot(i)-Xdotdot)^2;
+end
+SSb = SSb*n;
+Xijsquared = Xij.^2;
+SSW = sum(Xijsquared) - (m*n*(Xdotdot^2)) - SSb;
+sigma1 = SSW/((n*m)-m);
+sigma2 = SSb/(m-1);
+TS = sigma2/sigma1;
+disp(TS, "Value of the test statistic is");
\ No newline at end of file diff --git a/291/CH10/EX10.3c/eg10_3c.sce b/291/CH10/EX10.3c/eg10_3c.sce new file mode 100755 index 000000000..1252a8125 --- /dev/null +++ b/291/CH10/EX10.3c/eg10_3c.sce @@ -0,0 +1,33 @@ +Xij = [3.2 3.4 3.3 3.5; 3.4 3.0 3.7 3.3; 2.8 2.6 3.0 2.7];
+Xi = zeros(3,1);
+n= 4;
+m=3;
+for i=1:3
+ for j=1:4
+ Xi(i)= Xi(i) + Xij(i,j);
+ end
+end
+Xi = Xi/n;
+SSW= 0;
+for i=1:3
+ for j= 1:4
+ SSW = SSW + ((Xij(i,j)-Xi(i))^2)
+ end
+end
+sigma1 = SSW/((n*m)-m);
+Xdotdot = sum(Xi)/m;
+new = (Xi - Xdotdot)^2;
+SSb= n*sum(new);
+sigma2 = SSb/(m-1);
+TS = sigma2/sigma1;
+//disp(sigma1);
+//disp(sigma2);
+disp(TS, "Value of the test statistic is");
+pvalue = 1 - cdff("PQ", TS,m-1, ((n*m)-m) );
+disp(pvalue, "The p-value is")
+C = 3.95; //from table A5
+W = C*sqrt(SSW/(9*4));
+disp(W);
+disp(Xi(1)-Xi(2)+W ,"and ", Xi(1)-Xi(2)-W, "Mean1 - Mean2 lies between " );
+disp(Xi(1)-Xi(3)+W ,"and ", Xi(1)-Xi(3)-W, "Mean1 - Mean3 lies between " );
+disp(Xi(2)-Xi(3)+W ,"and ", Xi(2)-Xi(3)-W, "Mean2 - Mean3 lies between " );
\ No newline at end of file diff --git a/291/CH10/EX10.4b/eg10_4b.sce b/291/CH10/EX10.4b/eg10_4b.sce new file mode 100755 index 000000000..10372d044 --- /dev/null +++ b/291/CH10/EX10.4b/eg10_4b.sce @@ -0,0 +1,25 @@ +X=[75 73 60 70 86; 78 71 64 72 90; 80 69 62 70 85; 73 67 63 80 92 ];
+Xidot = zeros(4,1);
+for i=1:4
+ for j=1:5
+ Xidot(i)=Xidot(i) + X(i,j);
+ end
+end
+Xidot = Xidot/5;
+Xjdot = zeros(5,1);
+for j=1:5
+ for i=1:4
+ Xjdot(j)=Xjdot(j) + X(i,j);
+ end
+end
+Xjdot = Xjdot/4;
+Xdotdot = sum(Xidot)/4;
+//disp(Xdotdot)
+meanhat = Xdotdot;
+alphahat = Xidot - meanhat;
+betahat = Xjdot - meanhat;
+disp(meanhat, "The estimator of the mean is");
+disp("The alphas are-")
+disp(alphahat)
+disp("The betas are-")
+disp(betahat)
\ No newline at end of file diff --git a/291/CH10/EX10.5a/eg10_5a.sce b/291/CH10/EX10.5a/eg10_5a.sce new file mode 100755 index 000000000..b0a9fc100 --- /dev/null +++ b/291/CH10/EX10.5a/eg10_5a.sce @@ -0,0 +1,40 @@ +X = [53 35 31 37 40 43; 36 34 17 21 30 18; 47 37 17 31 45 26; 55 31 17 23 43 37; 40 32 19 26 45 37; 52 42 20 27 26 32; 39 28 21 21 36 28; 40 32 21 21 36 35];
+m= 8;
+n = 6;
+Xidot = zeros(8,1);
+for i=1:8
+ for j=1:6
+ Xidot(i)=Xidot(i) + X(i,j);
+ end
+end
+Xidot = Xidot/6;
+Xjdot = zeros(6,1);
+for j=1:6
+ for i=1:8
+ Xjdot(j)=Xjdot(j) + X(i,j);
+ end
+end
+Xjdot = Xjdot/8;
+Xdotdot = sum(Xidot)/8;
+new = (Xidot - Xdotdot)^2;
+SSr = n*sum(new);
+new1 = (Xjdot - Xdotdot)^2;
+SSc = m*sum(new1);
+SSe = 0;
+for i=1:m
+ for j=1:n
+ SSe = SSe + (X(i,j)-Xidot(i)-Xjdot(j)+ Xdotdot)^2;
+ end
+end
+N =(m-1)*(n-1);
+TS1 = SSr*N/((m-1)*SSe);
+TS2 = SSc*N/((n-1)*SSe);
+pvaluec = 1- cdff("PQ", TS1, m-1, N);
+pvaluer = 1- cdff("PQ", TS2, n-1, N);
+//disp(pvaluer, pvaluec);
+//disp(TS1, TS2);
+disp(TS1, "The value of the F-statistic for testing that there is no row effect is");
+disp(pvaluec, "The p-value for testing that there is no row effect is");
+
+disp(TS2, "The value of the F-statistic for testing that there is no column effect is");
+disp(pvaluer, "The p-value for testing that there is no column effect is");
diff --git a/291/CH11/EX11.2a/eg11_2a.sce b/291/CH11/EX11.2a/eg11_2a.sce new file mode 100755 index 000000000..6b66226bd --- /dev/null +++ b/291/CH11/EX11.2a/eg11_2a.sce @@ -0,0 +1,25 @@ +X = [90 100 87 96 101 86 119 118 121 114 113 106];
+pi= ones(12,1);
+pi= pi/12;
+new = X.^2;
+npi= sum(X)*pi;
+T = sum(new);
+T = T/npi;
+T = T - sum(X);
+disp("When there are 12 regions")
+disp(T(1), "The test statistic is")
+pvalue = 1- cdfchi("PQ",T(1), 11);
+disp(pvalue, "The pvalue is ")
+
+X = [277 283 358 333];
+pi= ones(4,1);
+pi= pi/4;
+new = X.^2;
+npi= sum(X)*pi;
+T = sum(new);
+T = T/npi;
+T = T - sum(X);
+disp("When there are 4 regions")
+disp(T(1), "The test statistic is")
+pvalue = 1- cdfchi("PQ",T(1), 3);
+disp(pvalue, "The pvalue is ")
\ No newline at end of file diff --git a/291/CH11/EX11.2b/eg11_2b.sce b/291/CH11/EX11.2b/eg11_2b.sce new file mode 100755 index 000000000..9511007fb --- /dev/null +++ b/291/CH11/EX11.2b/eg11_2b.sce @@ -0,0 +1,18 @@ +X = [3 6 9 7 5];
+p= [0.15 0.25 0.35 0.20 0.05];
+T= 0;
+n3=sum(X);
+np = p*n3;
+Xsqu = (X-np).^2;
+disp(Xsqu);
+XT = Xsqu./np;
+T = sum(XT);
+
+//T = T - sum(X);
+//disp("When there are 12 regions")
+disp(T, "The test statistic is")
+pvalue = 1- cdfchi("PQ",T(1), 4);
+//a= cdfchi("PQ",T(1), 4);
+
+disp(pvalue, "The pvalue is ")
+disp("Thus, the hypothesis would not be rejected at 5% level of significance")
\ No newline at end of file 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 diff --git a/291/CH11/EX11.3a/eg11_3a.sce b/291/CH11/EX11.3a/eg11_3a.sce new file mode 100755 index 000000000..218247c12 --- /dev/null +++ b/291/CH11/EX11.3a/eg11_3a.sce @@ -0,0 +1,44 @@ +Y = [8 0 0 1 3 4 0 2 12 5 1 8 0 2 0 1 9 3 4 5 3 3 4 7 4 0 1 2 1 2];
+weeks = 30;
+lamda = sum(Y)/weeks;
+p = zeros(5,1);
+p(1) = cdfpoi("PQ", 0, lamda);
+p(2) = cdfpoi("PQ", 1, lamda) - p(1);
+p(3) = cdfpoi("PQ", 3, lamda) - cdfpoi("PQ", 1, lamda);
+p(4) = cdfpoi("PQ", 5, lamda) - cdfpoi("PQ", 3, lamda);
+p(5) = 1 - cdfpoi("PQ", 5, lamda);
+//disp(p);
+X = zeros(5,1);
+for i=1:30
+ if(Y(i)==0)
+ X(1) = X(1) +1;
+ end
+ if(Y(i)==1)
+ X(2) = X(2) +1;
+ end
+ if(Y(i)==2)
+ X(3) = X(3) +1;
+ end
+ if(Y(i)==3)
+ X(3) = X(3) +1;
+ end
+ if(Y(i)==4)
+ X(4) = X(4) +1;
+ end
+ if(Y(i)==5)
+ X(4) = X(4) +1;
+ end
+ if(Y(i)>5)
+ X(5) = X(5) +1;
+ end
+end
+//disp(X);
+T= 0;
+npi = weeks * p;
+for i=1:5
+ T = T + ((X(i)-npi(i))^2)/npi(i);
+end
+disp(T, "T is");
+pvalue = 1- cdfchi("PQ", T, 3);
+disp(pvalue, "The p-value is")
+disp("Hypothesis of an underlying poisson distribution is rejected")
diff --git a/291/CH11/EX11.4a/eg11_4a.sce b/291/CH11/EX11.4a/eg11_4a.sce new file mode 100755 index 000000000..2511cf914 --- /dev/null +++ b/291/CH11/EX11.4a/eg11_4a.sce @@ -0,0 +1,36 @@ +Nij = [68 56 32; 52 72 20];
+n= sum(Nij);
+Ni = zeros(2,1);
+Mj = zeros(3,1);
+for i= 1:2
+ for j= 1:3
+ Ni(i) = Ni(i) + Nij(i,j);
+ end
+end
+for j= 1:3
+ for i= 1:2
+ Mj(j) = Mj(j) + Nij(i,j);
+ end
+end
+NM = ones(2,3);
+for i=1:2
+ for j=1:3
+ NM(i,j)= Ni(i)*Mj(j);
+ end
+end
+NM= NM/n;
+//disp(NM);
+TS = 0
+for i=1:2
+ for j= 1:3
+ TS = TS + ((Nij(i,j)-NM(i,j))^2)/NM(i,j);
+ end
+end
+disp(TS, "The test statistic is")
+compare = cdfchi("X", 2, 0.95, 0.05);
+//disp(compare)
+if(TS>compare)
+ disp("The null hypothesis is rejected at the 5% level of significance");
+else
+ disp("The null hypothesis is accepted at the 5% level of significance");
+end
\ No newline at end of file diff --git a/291/CH11/EX11.4b/eg11_4a.sce b/291/CH11/EX11.4b/eg11_4a.sce new file mode 100755 index 000000000..d9771d366 --- /dev/null +++ b/291/CH11/EX11.4b/eg11_4a.sce @@ -0,0 +1,36 @@ +Nij = [68 56 32; 52 72 20];
+n3= sum(Nij);
+Ni = zeros(2,1);
+Mj = zeros(3,1);
+for i= 1:2
+ for j= 1:3
+ Ni(i) = Ni(i) + Nij(i,j);
+ end
+end
+for j= 1:3
+ for i= 1:2
+ Mj(j) = Mj(j) + Nij(i,j);
+ end
+end
+NM = ones(2,3);
+for i=1:2
+ for j=1:3
+ NM(i,j)= Ni(i)*Mj(j);
+ end
+end
+NM= NM/n3;
+//disp(NM);
+TS = 0
+for i=1:2
+ for j= 1:3
+ TS = TS + ((Nij(i,j)-NM(i,j))^2)/NM(i,j);
+ end
+end
+disp(TS, "The test statistic is")
+compare = cdfchi("X", 2, 0.95, 0.05);
+//disp(compare)
+if(TS>compare)
+ disp("The null hypothesis is rejected at the 5% level of significance");
+else
+ disp("The null hypothesis is accepted at the 5% level of significance");
+end
\ No newline at end of file diff --git a/291/CH11/EX11.5a/eg11_5a.sce b/291/CH11/EX11.5a/eg11_5a.sce new file mode 100755 index 000000000..c7adf8e50 --- /dev/null +++ b/291/CH11/EX11.5a/eg11_5a.sce @@ -0,0 +1,36 @@ +Nij = [62 14; 9938 19986];
+n= sum(Nij);
+Ni = zeros(2,1);
+Mj = zeros(2,1);
+for i= 1:2
+ for j= 1:2
+ Ni(i) = Ni(i) + Nij(i,j);
+ end
+end
+for j= 1:2
+ for i= 1:2
+ Mj(j) = Mj(j) + Nij(i,j);
+ end
+end
+NM = ones(2,2);
+for i=1:2
+ for j=1:2
+ NM(i,j)= Ni(i)*Mj(j);
+ end
+end
+NM= NM/n;
+disp(NM);
+TS = 0
+for i=1:2
+ for j= 1:2
+ TS = TS + ((Nij(i,j)-NM(i,j))^2)/NM(i,j);
+ end
+end
+disp(TS, "The test statistic is")
+compare = cdfchi("X", 1, 0.99, 0.01);
+//disp(compare)
+if(TS>compare)
+ disp("The null hypothesis is rejected at the 5% level of significance");
+else
+ disp("The null hypothesis is accepted at the 5% level of significance");
+end
\ No newline at end of file diff --git a/291/CH11/EX11.5b/eg11_5b.sce b/291/CH11/EX11.5b/eg11_5b.sce new file mode 100755 index 000000000..ede350b63 --- /dev/null +++ b/291/CH11/EX11.5b/eg11_5b.sce @@ -0,0 +1,38 @@ +Nij = [28 30 58 55; 472 470 442 445];
+n= sum(Nij);
+Ni = zeros(2,1);
+Mj = zeros(4,1);
+for i= 1:2
+ for j= 1:4
+ Ni(i) = Ni(i) + Nij(i,j);
+ end
+end
+for j= 1:4
+ for i= 1:2
+ Mj(j) = Mj(j) + Nij(i,j);
+ end
+end
+NM = ones(2,4);
+for i=1:2
+ for j=1:4
+ NM(i,j)= Ni(i)*Mj(j);
+ end
+end
+NM= NM/n;
+//disp(NM);
+TS = 0
+for i=1:2
+ for j= 1:4
+ TS = TS + ((Nij(i,j)-NM(i,j))^2)/NM(i,j);
+ end
+end
+disp(TS, "The test statistic is")
+compare = cdfchi("X", 3, 0.99, 0.01);
+pvalue = 1- cdfchi("PQ", TS, 3);
+disp(pvalue, "The p-value is")
+//disp(compare)
+if(TS>compare)
+ disp("The null hypothesis is rejected at the 1% level of significance");
+else
+ disp("The null hypothesis is accepted at the 5% level of significance");
+end
\ No newline at end of file diff --git a/291/CH11/EX11.6a/eg11_6a.sce b/291/CH11/EX11.6a/eg11_6a.sce new file mode 100755 index 000000000..cd2bc29b0 --- /dev/null +++ b/291/CH11/EX11.6a/eg11_6a.sce @@ -0,0 +1,11 @@ +X= [66 72 81 94 112 116 124 140 145 155];
+D= 0.4831487;
+n= 10;
+Dgiven = 1.480;
+Dstar = (sqrt(n) + 0.12 + (0.11/sqrt(n)))*D;
+disp(Dstar, "Dstar is ");
+if(Dstar>Dgiven)
+ disp("Null hypothesis is rejected at 2.5% level of significance")
+else
+ disp("Null hypothesis is accepted at 2.5% level of significance")
+end
\ No newline at end of file diff --git a/291/CH12/EX12.2a/eg12_2a.sce b/291/CH12/EX12.2a/eg12_2a.sce new file mode 100755 index 000000000..b82cfcff7 --- /dev/null +++ b/291/CH12/EX12.2a/eg12_2a.sce @@ -0,0 +1,10 @@ +n= 200;
+v = 120;
+p =0.5;
+if(v < (n/2))
+ pvalue = 2*cdfbin("PQ", v, n, p,1-p);
+else
+ pvalue = 2*cdfbin("PQ", n-v, n, p,1-p);
+
+end
+disp(pvalue, "Pvalue is ");
\ No newline at end of file diff --git a/291/CH12/EX12.2b/eg12_2b.sce b/291/CH12/EX12.2b/eg12_2b.sce new file mode 100755 index 000000000..4c41e79c7 --- /dev/null +++ b/291/CH12/EX12.2b/eg12_2b.sce @@ -0,0 +1,7 @@ +n= 80;
+v = 28;
+p =0.5;
+
+ pvalue = cdfbin("PQ", v, n, p,1-p);
+disp(pvalue, "Pvalue is ");
+disp("Thus, the null hypothesis that the median income is less than or equal to $90,000 is rejected")
\ No newline at end of file diff --git a/291/CH12/EX12.3b/eg12_3b.sce b/291/CH12/EX12.3b/eg12_3b.sce new file mode 100755 index 000000000..d21958221 --- /dev/null +++ b/291/CH12/EX12.3b/eg12_3b.sce @@ -0,0 +1,23 @@ +n =4;
+mo = 2;
+X = [4.2 1.8 5.3 1.7];
+t =3;
+tstar= min(t, (n*(n+1)/2) - t);
+P = zeros(4,4);
+P(1,1)= 0.5;
+P(1,2) = 1;
+P(1,3) = 1;
+P(1,4) = 1;
+for i=2:4
+ for j = 1:4
+ if (j-i <1)
+ P(i,j) = 0.5*P(i-1, j);
+ //disp(j,i);
+ //disp(P(i,j))
+
+ else
+ P(i,j) = 0.5*(P(i-1,j-i)+P(i-1,j));
+ end
+ end
+end
+disp(P)
\ No newline at end of file diff --git a/291/CH12/EX12.3c/eg12_3c.sce b/291/CH12/EX12.3c/eg12_3c.sce new file mode 100755 index 000000000..f868b4b97 --- /dev/null +++ b/291/CH12/EX12.3c/eg12_3c.sce @@ -0,0 +1,20 @@ +n =20;
+t =142;
+tstar= min(t, (n*(n+1)/2) - t);
+P = ones(20,tstar+1);
+P(1,1)= 0.5;
+P(1,2) = 1;
+for i=2:20
+ for j = 1:tstar+1 if (j-i <1)
+ P(i,j) = 0.5*P(i-1, j);
+ //disp(j,i);
+ //disp(P(i,j))
+
+ else
+ P(i,j) = 0.5*(P(i-1,j-i)+P(i-1,j));
+ end
+ end
+end
+//disp(P)
+pvalue= 2*P(20,tstar+1);
+disp(pvalue, "Pvalue is")
\ No newline at end of file diff --git a/291/CH12/EX12.4a/eg12_4a.sce b/291/CH12/EX12.4a/eg12_4a.sce new file mode 100755 index 000000000..62d584bdd --- /dev/null +++ b/291/CH12/EX12.4a/eg12_4a.sce @@ -0,0 +1,16 @@ +X= [65.2 67.1 69.4 78.2 74 80.3];
+Y = [59.4 72.1 68 66.2 58.5];
+Z = [X Y];
+Z = gsort(Z,'g','i');
+[m n]= size(X);
+[p q] = size(Z)
+T = 0;
+for i=1:n
+ test = X(i);
+ for j =1 : q
+ if(test== Z(j))
+ T = T+ j;
+ end
+ end
+end
+disp(T, "The test statistic is ")
\ No newline at end of file diff --git a/291/CH12/EX12.4b/eg12_4b.sce b/291/CH12/EX12.4b/eg12_4b.sce new file mode 100755 index 000000000..9b5114092 --- /dev/null +++ b/291/CH12/EX12.4b/eg12_4b.sce @@ -0,0 +1,26 @@ +function result= prob(N, M, K)
+ if(N==1 & M==0)
+ if(K >0)
+ result = 1;
+ else
+ result =0;
+ end
+
+ elseif (N==0 & M==1)
+ if(K <0)
+ result = 0;
+ else
+ result =1;
+ end
+ elseif (N==0 & M==0 &K==0)
+ result =1;
+ else
+ result = (prob(N-1, M, K-N-M)*N/(N+M)) + (prob(N, M-1, K)*M/(N+M));
+ //result = prob(N-1, M, K-N-M)*N/(N+M) + prob(N, M-1, K);
+ //result = result + prob(N, M-1, K);
+ end
+endfunction
+
+function result =pval(n,m,t)
+ result = 2*min(prob(n,m,t), 1-prob(n,m,t-1));
+endfunction
\ No newline at end of file diff --git a/291/CH12/EX12.4c/eg12_4c.sce b/291/CH12/EX12.4c/eg12_4c.sce new file mode 100755 index 000000000..13fea91c4 --- /dev/null +++ b/291/CH12/EX12.4c/eg12_4c.sce @@ -0,0 +1,2 @@ +ans = pval(5,6,21);
+disp(ans)
\ No newline at end of file diff --git a/291/CH12/EX12.4d/eg12_4d.sce b/291/CH12/EX12.4d/eg12_4d.sce new file mode 100755 index 000000000..334bdc66e --- /dev/null +++ b/291/CH12/EX12.4d/eg12_4d.sce @@ -0,0 +1,2 @@ +ans = pval(9,13,72);
+disp(ans)
\ No newline at end of file diff --git a/291/CH12/EX12.4e/eg12_4e.sce b/291/CH12/EX12.4e/eg12_4e.sce new file mode 100755 index 000000000..06712f80d --- /dev/null +++ b/291/CH12/EX12.4e/eg12_4e.sce @@ -0,0 +1,19 @@ +n1 =5;
+m1= 6;
+
+t1 =21;
+num1 = n1*(n1+m1+1)/2;
+d1=abs(t1 - num1);
+val = d1/sqrt(n1*m1*(n1+m1+1)/12);
+//disp(d1, "d is")
+//disp(val, "val is")
+pval = 2*(1-cdfnor("PQ", val, 0,1));
+disp(pval, "The p-value for eg 12.4a is")
+n2 =9;
+m2= 13;
+t2 =72;
+d2=abs(t2 - n2*(n2+m2+1)/2);
+
+val = d2/sqrt(n2*m2*(n2+m2+1)/12);
+pval = 2*(1-cdfnor("PQ", val, 0,1));
+disp(pval, "The p-value for eg 12.4d is")
\ No newline at end of file diff --git a/291/CH12/EX12.5a/12_5anew.sce b/291/CH12/EX12.5a/12_5anew.sce new file mode 100755 index 000000000..d67290f90 --- /dev/null +++ b/291/CH12/EX12.5a/12_5anew.sce @@ -0,0 +1,32 @@ +function result= fact(num)
+ if(num<=0)
+ result= 1
+ else
+ result = factorial(num)
+ end
+endfunction
+function result = proba(n,m,k)
+ if(pmodulo(k,2)==0)
+ k=k/2;
+ result = 2*fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)^2*fact(m-k)*fact(n-k)*fact(n+m));
+ else
+ k = (k-1)/2;
+ result = fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)*fact(k)*fact(m-k)*fact(n-k-1)*fact(n+m)) + fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)*fact(k)*fact(m-k-1)*fact(n-k)*fact(n+m));
+ end
+endfunction
+
+r1 = 20;
+n1 = 20;
+m1=10;
+ans1 =0;
+for i=1:19
+ ans1 =ans1 + proba(n1,m1,i);
+ //disp(proba(n,m,i));
+ //disp(ans1)
+end
+if(ans1<0.5)
+ pvalue1 = 2*ans1;
+else
+ pvalue1 = 2*(1-ans1);
+end
+disp(pvalue1, "P-value is")
\ No newline at end of file diff --git a/291/CH12/EX12.5c/eg12_5c.sce b/291/CH12/EX12.5c/eg12_5c.sce new file mode 100755 index 000000000..e57260b9b --- /dev/null +++ b/291/CH12/EX12.5c/eg12_5c.sce @@ -0,0 +1,10 @@ +u = 61;
+sigma = 5.454;
+r =75;
+val = cdfnor("PQ", (r-u)/sigma, 0,1);
+if(val>0.5)
+ pvalue = 2*(1-val);
+else
+ pvalue = 2*val;
+end
+disp(pvalue, "P-value is");
\ No newline at end of file diff --git a/291/CH13/EX13.2a/eg13_2a.sce b/291/CH13/EX13.2a/eg13_2a.sce new file mode 100755 index 000000000..f42b0c343 --- /dev/null +++ b/291/CH13/EX13.2a/eg13_2a.sce @@ -0,0 +1,19 @@ +X = [3.01 2.97 3.12 2.99 3.03 3.02 3.10 3.14 3.09 3.20];
+Y = 1:1:10;
+u = 3;
+sigma = 0.1;
+n=4;
+ucl = u + (3*sigma/sqrt(n));
+lcl = u - (3*sigma/sqrt(n));
+Z= 0.1:0.1:10;
+P= ones(1,100);
+Q= ones(1,100);
+P =P*ucl;
+Q =Q*lcl;
+plot2d(Y, X, -2);
+plot2d(Z, P, 1);
+plot2d(Z, Q, 1);
+//disp(size(Z));
+//disp(size(P));
+disp(ucl, 'ucl is');
+disp(lcl, 'lcl is')
\ No newline at end of file diff --git a/291/CH13/EX13.2b/eg13_2b.sce b/291/CH13/EX13.2b/eg13_2b.sce new file mode 100755 index 000000000..94546eadb --- /dev/null +++ b/291/CH13/EX13.2b/eg13_2b.sce @@ -0,0 +1,17 @@ +Xbar = [3.01 2.97 3.12 2.99 3.03 3.02 3.10 3.14 3.09 3.20];
+S = [0.12 0.14 0.08 0.11 0.09 0.08 0.15 0.16 0.13 0.16];
+c = [0.7978849 0.8862266 0.9213181 0.9399851 0.9515332 0.9593684 0.9650309 0.9693103 0.9726596];
+n=4;
+Xbarbar= mean(Xbar);
+Sbar =mean(S);
+lcl = Xbarbar - (3*Sbar/(sqrt(n)*c(n-1)));
+ucl = Xbarbar + (3*Sbar/(sqrt(n)*c(n-1)));
+//disp(lcl, "LCL is")
+//disp(ucl, "UCL is")
+u = Xbarbar;
+sigma= Sbar/c(n-1);
+//disp(u);
+//disp(sigma);
+//disp(Sbar, c(4));
+prob = cdfnor("PQ", 3.1, u, sigma) - cdfnor("PQ", 2.9, u, sigma);
+disp(prob*100, "Percentage of the items that will meet the specifications is")
\ No newline at end of file diff --git a/291/CH13/EX13.3a/13_3aa.png b/291/CH13/EX13.3a/13_3aa.png Binary files differnew file mode 100755 index 000000000..be92906dd --- /dev/null +++ b/291/CH13/EX13.3a/13_3aa.png diff --git a/291/CH13/EX13.3a/13_3ab.png b/291/CH13/EX13.3a/13_3ab.png Binary files differnew file mode 100755 index 000000000..ada4dadda --- /dev/null +++ b/291/CH13/EX13.3a/13_3ab.png diff --git a/291/CH13/EX13.3a/eg13_3a.sce b/291/CH13/EX13.3a/eg13_3a.sce new file mode 100755 index 000000000..6922655a9 --- /dev/null +++ b/291/CH13/EX13.3a/eg13_3a.sce @@ -0,0 +1,38 @@ +Xbar = [35.1 33.2 31.7 35.4 34.5 36.4 35.9 38.4 35.7 27.2 38.1 37.6 38.8 34.3 43.2 41.3 35.7 36.3 35.4 34.6];
+S = [4.2 4.4 2.5 3.2 2.6 4.5 3.4 5.1 3.8 6.2 4.2 3.9 3.2 4 3.5 8.2 8.1 4.2 4.1 3.7];
+c = [0.7978849 0.8862266 0.9213181 0.9399851 0.9515332 0.9593684 0.9650309 0.9693103 0.9726596];
+Y = 1:1:20;
+n =5;
+Z= 0.1:0.1:20;
+Xbarbar = mean(Xbar);
+Sbar = mean(S);
+lclX = Xbarbar - (3*Sbar/(sqrt(n)*c(n-1)));
+uclX = Xbarbar + (3*Sbar/(sqrt(n)*c(n-1)));
+val1 = 1/c(n-1);
+val1 = val1^2;
+val1 = val1 - 1;
+val = sqrt(val1);
+//val = sqrt((1/c(n-1)^2)) - 1;
+ucls = Sbar*(1+(3*val));
+lcls = Sbar*(1-(3*val));
+//disp(ucls, lcls)
+plot2d(Y, Xbar, -2);
+P= ones(1, 200);
+Q = ones(1, 200);
+P= P*lclX;
+Q=Q*uclX;
+disp(uclX, 'UCL(X)=');
+disp(lclX, 'LCL(X)=');
+plot2d(Z, P, 1);
+plot2d(Z, Q, 1);
+title('Control Chart for X')
+scf(2);
+disp(uclX, 'UCL(S)=');
+disp(lclX, 'LCL(S)=');
+//disp(ucls, lcls)
+plot2d(Y, S, -2);
+P= P*lcls/lclX;
+Q=Q*ucls/uclX;
+plot2d(Z, P, 1);
+plot2d(Z, Q, 1);
+title('Control Chart for S')
\ No newline at end of file diff --git a/291/CH13/EX13.4a/eg13_4a.sce b/291/CH13/EX13.4a/eg13_4a.sce new file mode 100755 index 000000000..492c9c724 --- /dev/null +++ b/291/CH13/EX13.4a/eg13_4a.sce @@ -0,0 +1,26 @@ +defect = [6 5 3 0 1 2 1 0 2 1 1 3 2 0 1 1 0 2 1 2];
+F = [0.12 0.10 0.06 0.00 0.02 0.04 0.02 0.00 0.04 0.02 0.02 0.06 0.04 0.00 .02 0.02 0.00 0.04 0.02 0.04];
+total = 1000;
+Fbar = sum(defect)/total;
+n=50;
+val = sqrt(Fbar*(1-Fbar)/n);
+lcl = Fbar - (3*val);
+ucl = Fbar + (3*val);
+disp(lcl,"LCL is" );
+disp(ucl, "UCL is");
+for i= 1:20
+ if( F(i)>ucl | F(i)<lcl)
+ totald=sum(defect)-defect(i);
+ //total = total -50;
+ end
+end
+//disp(totald);
+total = total - 50;
+Fbar = totald/total;
+val = sqrt(Fbar*(1-Fbar)/n);
+//disp(Fbar);
+disp("After recomputation");
+lcl = Fbar - (3*val);
+ucl = Fbar + (3*val);
+disp(lcl,"LCL is" );
+disp(ucl, "UCL is");
\ No newline at end of file diff --git a/291/CH13/EX13.5a/eg13_5a.sce b/291/CH13/EX13.5a/eg13_5a.sce new file mode 100755 index 000000000..44c7fa500 --- /dev/null +++ b/291/CH13/EX13.5a/eg13_5a.sce @@ -0,0 +1,34 @@ +X = [141 162 150 111 92 74 85 95 76 68 63 74 103 81 94 68 95 81 102 73];
+total = sum(X);
+num = 20;
+Xbar = mean(X);
+lcl = Xbar - 3*sqrt(Xbar);
+ucl = Xbar + 3*sqrt(Xbar);
+disp(ucl, "UCL is");
+disp(lcl, "LCL is");
+for i =1:20
+ if(X(i)> ucl )
+ total = total - X(i);
+ num= num -1;
+ end
+end
+Xbar = total/num;
+
+lcl = Xbar - 3*sqrt(Xbar);
+ucl = Xbar + 3*sqrt(Xbar);
+disp("After recomputation")
+disp(ucl, "UCL is");
+disp(lcl, "LCL is");
+total = total - X(4);
+num = num-1;
+disp(Xbar, "Xbar is");
+disp(X(4), " is");
+Xbar = total/num;
+lcl = Xbar - 3*sqrt(Xbar);
+ucl = Xbar + 3*sqrt(Xbar);
+disp("After second recomputation")
+disp(ucl, "UCL is");
+disp(lcl, "LCL is");
+disp(Xbar, "It appears that the process is in control with mean");
+
+//The mean after the second recomputation is incoreectly calculated in the textbook. It should be
((17*84.41)-111 )/16 = 82.748 whereas the value given in the book is 82.56. The values of UCL and LCL
change accordingly.
\ No newline at end of file diff --git a/291/CH13/EX13.6b/eg13_6b.sce b/291/CH13/EX13.6b/eg13_6b.sce new file mode 100755 index 000000000..7f703bbc5 --- /dev/null +++ b/291/CH13/EX13.6b/eg13_6b.sce @@ -0,0 +1,16 @@ +X = [48 52 70 62 57 81 56 59 77 82 78 80 74 82 68 84];
+u = 62;
+n = 4;
+sigma = 24;
+alpha = 0.25;
+W = zeros(17);
+W(1) = 60;
+for i =2:17
+ W(i) = (0.25*X(i-1)) + (0.75*W(i-1));
+end
+disp(W , "The values of W are")
+val = 3*sigma*sqrt(alpha/(n*(2-alpha)));
+lcl = u- val;
+ucl = u+ val;
+disp(lcl, "LCL is");
+disp(ucl, "UCL is");
\ No newline at end of file diff --git a/291/CH13/EX13.6c/13_6c.png b/291/CH13/EX13.6c/13_6c.png Binary files differnew file mode 100755 index 000000000..82955b248 --- /dev/null +++ b/291/CH13/EX13.6c/13_6c.png diff --git a/291/CH13/EX13.6c/eg13_6c.sce b/291/CH13/EX13.6c/eg13_6c.sce new file mode 100755 index 000000000..830e67d4f --- /dev/null +++ b/291/CH13/EX13.6c/eg13_6c.sce @@ -0,0 +1,32 @@ +X = [9.617728 10.25437 9.867195 10.79338 10.60699 10.48396 13.33961 9.462969 10.14556 11.66342 11.55484 11.26203 12.31473 9.220009 11.25206 10.48662 9.025091 9.693386 11.45989 12.44213 11.18981 11.56674 9.869849 12.11311 11.48656];
+t = 1:1:26;
+alpha = 2/9;
+val = 9.915051 - (alpha*9.617728);
+val = val/(1-alpha);
+disp(val, "val is");
+u = 10;
+n = 5;
+sigma = 2;
+
+W = zeros(26);
+W(1) = 10.;
+for i =2:26
+ W(i) = (alpha*X(i-1)) + ((1-alpha)*W(i-1));
+end
+disp(W , "The values of W are");
+val = 3*sigma*sqrt(alpha/(n*(2-alpha)));
+lcl = u- val;
+ucl = u+ val;
+disp(lcl, "LCL is");
+disp(ucl, "UCL is");
+plot2d(t,W, -2);
+xlabel("t");
+ylabel("W");
+nlcl = ones(1, 26);
+nlcl= nlcl.* lcl;
+plot2d(t,nlcl);
+nucl = ones(1, 26);
+nucl= nucl.* ucl;
+plot2d(t,nucl);
+
+//The asymptpotic lines for UCL and LCL have been plotted
\ No newline at end of file diff --git a/291/CH13/EX13.6d/eg13_6d.sce b/291/CH13/EX13.6d/eg13_6d.sce new file mode 100755 index 000000000..13739a0fe --- /dev/null +++ b/291/CH13/EX13.6d/eg13_6d.sce @@ -0,0 +1,23 @@ +X = [29 33 35 42 36 44 43 45];
+u =30;
+sig = 8;
+d =0.5;
+B =5;
+Y = X - u - (d*sig);
+S = zeros(9);
+S(1) =0;
+for i=2:9
+ S(i)= max(S(i-1) + Y(i-1), 0);
+end
+disp(S, "S is")
+cl = B*sig;
+disp(cl)
+answer =100;
+for i=1:9
+ if(S(i)>cl)
+ answer = i;
+ end
+end
+disp("The mean has increased after observing the ")
+disp(answer-1);
+disp(" subgroup average");
\ No newline at end of file diff --git a/291/CH14/EX14.3a/eg14_3a.sce b/291/CH14/EX14.3a/eg14_3a.sce new file mode 100755 index 000000000..45aab4d71 --- /dev/null +++ b/291/CH14/EX14.3a/eg14_3a.sce @@ -0,0 +1,14 @@ +total =50;
+failure = 15;
+alpha = 0.05;
+t =525;
+val1 = cdfchi("X", 2*failure, alpha/2 , 1-(alpha/2));
+val2 = cdfchi("X", 2*failure, 1-alpha/2 , (alpha/2));
+
+int1 = 2*t/val1;
+int2 = 2*t/val2;
+disp("The 95% confidence interval is");
+disp(int2);
+disp(int1, "to");
+
+//The confidence interval is from 22.35 to 62.17 whereas my solution in Scilab is 22.35 to 62.53
because of the difference in the value of chi-square(0.975, 30). The textbook says the value is 16.89
whereas scilab calculates its value as 16.79
diff --git a/291/CH14/EX14.3b/eg14_3b.sce b/291/CH14/EX14.3b/eg14_3b.sce new file mode 100755 index 000000000..1cd69204e --- /dev/null +++ b/291/CH14/EX14.3b/eg14_3b.sce @@ -0,0 +1,5 @@ +t = 1800;
+theta = 150;
+r =20;
+pvalue = cdfchi("PQ",2*t/theta, 2*r );
+disp(pvalue, "P-value is ")
\ No newline at end of file diff --git a/291/CH14/EX14.3c/eg14_3c.sce b/291/CH14/EX14.3c/eg14_3c.sce new file mode 100755 index 000000000..67c17e819 --- /dev/null +++ b/291/CH14/EX14.3c/eg14_3c.sce @@ -0,0 +1,12 @@ +T = 500;
+alpha = 0.05;
+r = 10;
+val1 = cdfchi("X", 2*r, 1-alpha/2, alpha/2);
+val2 = cdfchi("X", 2*r, alpha/2, 1- alpha/2);
+int1= 2*T/val1;
+int2= 2*T/val2;
+disp("The 95% confidence interval is");
+disp(int1);
+disp(int2, "to");
+
+ //The confidence interval is from 29.27 to 103.52 whereas my solution in Scilab is 29.265774 to
104.26683 because of the difference in the value of chi-square(0.975, 30). The textbook says the value is
9.66 whereas scilab calculates its value as 9.5907774 .
\ No newline at end of file diff --git a/291/CH14/EX14.3d/eg14_3d.sce b/291/CH14/EX14.3d/eg14_3d.sce new file mode 100755 index 000000000..4ef967626 --- /dev/null +++ b/291/CH14/EX14.3d/eg14_3d.sce @@ -0,0 +1,8 @@ +r = 30;
+T = 600;
+theta = 25;
+val1 = cdfchi("PQ", 2*T/theta, 2*r);
+val2 = 1- cdfchi("PQ", 2*T/theta, 2*(r+1));
+pvalue = min(val1, val2);
+disp(pvalue, "The pvalue is");
+disp("H0 would be accepted when the significance level is 0.10");
\ No newline at end of file diff --git a/291/CH14/EX14.3e/eg14_3e.sce b/291/CH14/EX14.3e/eg14_3e.sce new file mode 100755 index 000000000..f54bf4849 --- /dev/null +++ b/291/CH14/EX14.3e/eg14_3e.sce @@ -0,0 +1,8 @@ +X = [5 7 6.2 8.1 7.9 15 18 3.9 4.6 5.8];
+Y= [3 3.2 4.1 1.8 1.6 2.7 1.2 5.4 10.3 1.5];
+t = sum(X)+sum(Y);
+R =10;
+a = 20;
+b = 2;
+estimate = (R+b)/(a+t);
+disp(estimate, "Bayes estimate of lambda is");
\ No newline at end of file diff --git a/291/CH14/EX14.4a/eg14_4a.sce b/291/CH14/EX14.4a/eg14_4a.sce new file mode 100755 index 000000000..90b5b5227 --- /dev/null +++ b/291/CH14/EX14.4a/eg14_4a.sce @@ -0,0 +1,10 @@ +Xlife = 420;
+Ylife = 510;
+Xnum= 10;
+Ynum =15;
+ts = Xlife*Ynum/(Ylife*Xnum);
+disp(ts, "The value of the test statistic is");
+val = cdff("PQ", ts, Xnum, Ynum);
+pvalue = 2*(1-val);
+disp(pvalue, "The p-value is");
+disp("We cannot reject H0");
diff --git a/291/CH2/EX2.2a/eg2_2a.sce b/291/CH2/EX2.2a/eg2_2a.sce new file mode 100755 index 000000000..1ee92f172 --- /dev/null +++ b/291/CH2/EX2.2a/eg2_2a.sce @@ -0,0 +1,6 @@ +starting_salary = [47 48 49 50 51 52 53 54 56 57 60];
+frequency = [4 1 3 5 8 10 0 5 2 3 1];
+total = sum(frequency);
+relative_frequency = frequency/total;
+disp("The relative frequencies are ")
+disp(relative_frequency)
\ No newline at end of file diff --git a/291/CH2/EX2.2b/2_2bgraph.png b/291/CH2/EX2.2b/2_2bgraph.png Binary files differnew file mode 100755 index 000000000..f3e2adab1 --- /dev/null +++ b/291/CH2/EX2.2b/2_2bgraph.png diff --git a/291/CH2/EX2.2b/eg2_2b.sce b/291/CH2/EX2.2b/eg2_2b.sce new file mode 100755 index 000000000..86ed05c7d --- /dev/null +++ b/291/CH2/EX2.2b/eg2_2b.sce @@ -0,0 +1,8 @@ +values = [42 50 32 55 9 12];
+percentages = values*100 / sum(values);
+new_text = string(percentages);
+text = ["Lung ", "Breast ", "Colon ", "Prostate ", "Melanoma ", "Bladder "];
+percentage_sign = ["%", "%", "%", "%", "%", "%"];
+final_text = text + new_text + percentage_sign;
+//pie([42 50 32 55 9 12], ["Lung", "Breast", "Colon", "Prostate", "Melanoma", "Bladder"]);
+pie(values , final_text);
diff --git a/291/CH2/EX2.3a/eg2_3a.sce b/291/CH2/EX2.3a/eg2_3a.sce new file mode 100755 index 000000000..636998c8a --- /dev/null +++ b/291/CH2/EX2.3a/eg2_3a.sce @@ -0,0 +1,4 @@ +scores=[284, 280, 277, 282, 279, 285, 281, 283, 278, 277];
+new_scores = scores - 280;
+final_mean = mean(new_scores)+ 280;
+disp(final_mean)
\ No newline at end of file diff --git a/291/CH2/EX2.3b/eg2_3b.sce b/291/CH2/EX2.3b/eg2_3b.sce new file mode 100755 index 000000000..a60b16187 --- /dev/null +++ b/291/CH2/EX2.3b/eg2_3b.sce @@ -0,0 +1,7 @@ +age= [15 16 17 18 19 20];
+frequencies = [2 5 11 9 14 13];
+product = age.*frequencies;
+total_people = sum(frequencies);
+mean_age = sum(product)/total_people ;
+disp("The sample mean of the ages is")
+disp(mean_age)
\ No newline at end of file diff --git a/291/CH2/EX2.3c/eg2_3c.sce b/291/CH2/EX2.3c/eg2_3c.sce new file mode 100755 index 000000000..192908c09 --- /dev/null +++ b/291/CH2/EX2.3c/eg2_3c.sce @@ -0,0 +1,13 @@ +age= [15 16 17 18 19 20];
+frequencies = [2 5 11 9 14 13];
+i=1;
+for j=1:6
+ for k = 1:frequencies(j)
+ final_age(i) = age(j);
+ i = i +1 ;
+ end;
+end
+
+
+final_median = median(final_age);
+disp(final_median);
\ No newline at end of file diff --git a/291/CH2/EX2.3d/eg2_3d.sce b/291/CH2/EX2.3d/eg2_3d.sce new file mode 100755 index 000000000..7aab989e1 --- /dev/null +++ b/291/CH2/EX2.3d/eg2_3d.sce @@ -0,0 +1,7 @@ +germ_free_mice = [158 192 193 194 195 202 212 215 229 230 237 240 244 247 259 301 301 321 337 415 434 444 485 496 529 537 624 707 800];
+conventional_mice = [159 189 191 198 235 245 250 256 261 265 266 280 343 356 383 403 414 428 432];
+disp (mean(germ_free_mice), "Sample mean for germ-free mice is ");
+disp (median(germ_free_mice), "Sample median for germ-free mice is ");
+disp (mean(conventional_mice), "Sample mean for conventional mice is ");
+disp (median(conventional_mice), "Sample mean for conventional mice is ");
+
diff --git a/291/CH2/EX2.3e/eg2_3e.sce b/291/CH2/EX2.3e/eg2_3e.sce new file mode 100755 index 000000000..5bd5d3fdf --- /dev/null +++ b/291/CH2/EX2.3e/eg2_3e.sce @@ -0,0 +1,21 @@ +value = [1 2 3 4 5 6];
+frequencies= [9 8 5 5 6 7];
+i=1;
+for j=1:6
+ for k = 1:frequencies(j)
+ final_value(i) = value(j);
+ i = i +1 ;
+ end;
+end
+product = value.*frequencies;
+disp(product , sum(product))
+
+total_value = sum(frequencies);
+mean_value = sum(product)/total_value ; //the answer in the textbook is incorrect
+[m1 m2]= max(frequencies);
+n= m2;
+
+disp("The sample mean is")
+disp(mean_value)
+disp(median(final_value), "The median is")
+disp(value(n) , "The mode is")
\ No newline at end of file diff --git a/291/CH2/EX2.3f/eg2_3f.sce b/291/CH2/EX2.3f/eg2_3f.sce new file mode 100755 index 000000000..c4d597b97 --- /dev/null +++ b/291/CH2/EX2.3f/eg2_3f.sce @@ -0,0 +1,4 @@ +A = [ 3 4 6 7 10];
+B= [-20 5 15 24];
+disp(variance(A), "The sample variance of A is")
+disp(variance(B), "The sample variance of B is")
\ No newline at end of file diff --git a/291/CH2/EX2.3g/eg2_3g.sce b/291/CH2/EX2.3g/eg2_3g.sce new file mode 100755 index 000000000..f930abcfd --- /dev/null +++ b/291/CH2/EX2.3g/eg2_3g.sce @@ -0,0 +1,3 @@ +accidents = [22 22 26 28 27 25 30 29 24];
+new_accidents = accidents - 22;
+disp(variance(new_accidents), "The variance of the number of accidents is")
\ No newline at end of file diff --git a/291/CH2/EX2.3h/eg2_3h.sce b/291/CH2/EX2.3h/eg2_3h.sce new file mode 100755 index 000000000..c53f0e223 --- /dev/null +++ b/291/CH2/EX2.3h/eg2_3h.sce @@ -0,0 +1,5 @@ +population = [7333253 3448613 2731743 1702086 1524249 1151977 1048949 1022830 998905 992038 816884 752279 734676 702979 665070 635913 617044 614289 579307 567094 547727 520947 514013 504505 493559];
+disp(perctl(population, 10), "The sample 10 percentile is")
+disp(perctl(population, 80), "The sample 80 percentile is")
+disp(perctl(population, 50), "The sample 80 percentile is")
+disp(median(population), "The median is")
\ No newline at end of file diff --git a/291/CH2/EX2.3i/eg2_3i.sce b/291/CH2/EX2.3i/eg2_3i.sce new file mode 100755 index 000000000..dff62f095 --- /dev/null +++ b/291/CH2/EX2.3i/eg2_3i.sce @@ -0,0 +1,2 @@ +noise = [ 82 89 94 110 74 122 112 95 100 78 65 60 90 83 87 75 114 85 69 94 124 115 107 88 97 74 72 68 83 91 90 102 77 125 108 65];
+disp(quart(noise), "The quartiles are")
\ No newline at end of file diff --git a/291/CH2/EX2.4a/eg2_4a.sce b/291/CH2/EX2.4a/eg2_4a.sce new file mode 100755 index 000000000..a6ca40930 --- /dev/null +++ b/291/CH2/EX2.4a/eg2_4a.sce @@ -0,0 +1,5 @@ +cars = [448162 404192 368327 318308 272122 260486 249128 234936 218540 207977];
+interval1 = mean(cars) - (1.5*st_deviation(cars));
+interval2 = mean(cars) + (1.5*st_deviation(cars));
+data = 100*5/9;
+disp(interval2, , "to" , interval1, "Atleast 55.55% of the data lies in the interval" );
diff --git a/291/CH2/EX2.5a/eg2_5a.sce b/291/CH2/EX2.5a/eg2_5a.sce new file mode 100755 index 000000000..f628c5447 --- /dev/null +++ b/291/CH2/EX2.5a/eg2_5a.sce @@ -0,0 +1,8 @@ +data = [90 91 94 83 85 85 87 88 72 74 74 75 77 77 78 60 62 63 64 66 66 52 55 55 56 58 43 46];
+disp("According to the empirical rule")
+disp("68% of the data lies between")
+disp(mean(data)+st_deviation(data), "and", mean(data)-st_deviation(data))
+disp("95% of the data lies between")
+disp(mean(data)+(2*st_deviation(data)), "and", mean(data)-(2*st_deviation(data)) )
+disp("99.7% of the data lies between")
+disp(mean(data)+(3*st_deviation(data)), "and", mean(data)-(3*st_deviation(data)))
\ No newline at end of file diff --git a/291/CH2/EX2.6a/eg2_6a.sce b/291/CH2/EX2.6a/eg2_6a.sce new file mode 100755 index 000000000..34f9e0e65 --- /dev/null +++ b/291/CH2/EX2.6a/eg2_6a.sce @@ -0,0 +1,14 @@ +temp = [24.2 22.7 30.5 28.6 25.5 32.0 28.6 26.5 25.3 26.0 24.4 24.8 20.6 25.1 21.4 23.7 23.9 25.2 27.4 28.3 28.8 26.6];
+defects = [25 31 36 33 19 24 27 25 16 14 22 23 20 25 25 23 27 30 33 32 35 24];
+temp_new = temp- mean(temp);
+defects_new = defects - mean(defects);
+num=0
+s1 =0;
+s2=0;
+for i=1:22
+ num = num + (temp_new(i)*defects_new(i));
+ s1 = s1 + (temp_new(i)*temp_new(i));
+ s2 = s2 + (defects_new(i)*defects_new(i));
+end
+coefficient = num/sqrt(s1*s2);
+disp(coefficient)
\ No newline at end of file diff --git a/291/CH2/EX2.6b/eg2_6b.sce b/291/CH2/EX2.6b/eg2_6b.sce new file mode 100755 index 000000000..1aedf4278 --- /dev/null +++ b/291/CH2/EX2.6b/eg2_6b.sce @@ -0,0 +1,14 @@ +year = [12 16 13 18 19 12 18 19 12 14];
+pulserate = [73 67 74 63 73 84 60 62 76 71];
+year_new = year- mean(year);
+pulserate_new = pulserate - mean(pulserate);
+num=0
+s1 =0;
+s2=0;
+for i=1:10
+ num = num + (year_new(i)*pulserate_new(i));
+ s1 = s1 + (year_new(i)*year_new(i));
+ s2 = s2 + (pulserate_new(i)*pulserate_new(i));
+end
+coefficient = num/sqrt(s1*s2);
+disp(coefficient)
\ No newline at end of file diff --git a/291/CH3/EX3.4a/eg3_4a.sce b/291/CH3/EX3.4a/eg3_4a.sce new file mode 100755 index 000000000..9338a25c4 --- /dev/null +++ b/291/CH3/EX3.4a/eg3_4a.sce @@ -0,0 +1,5 @@ +cigarette = 0.28;
+cigar = 0.07;
+cigar_and_cigarette = 0.05 ;
+cigar_or_cigarette = cigarette + cigar - cigar_and_cigarette;
+disp( "% of the males smoke neither cigar nor cigarette", (1-cigar_or_cigarette)*100 )
\ No newline at end of file diff --git a/291/CH3/EX3.5a/eg3_5a.sce b/291/CH3/EX3.5a/eg3_5a.sce new file mode 100755 index 000000000..e39708760 --- /dev/null +++ b/291/CH3/EX3.5a/eg3_5a.sce @@ -0,0 +1,7 @@ +white_balls= 6;
+black_balls = 5;
+total = white_balls + black_balls;
+probability_whiteandblack = white_balls*black_balls/(total*(total-1));
+probability_blackandwhite = white_balls*black_balls/(total*(total-1));
+reqd_probability = probability_whiteandblack + probability_blackandwhite;
+disp(reqd_probability, "Thus, the required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.5b/eg3_5b.sce b/291/CH3/EX3.5b/eg3_5b.sce new file mode 100755 index 000000000..67cda7548 --- /dev/null +++ b/291/CH3/EX3.5b/eg3_5b.sce @@ -0,0 +1,6 @@ +maths = 4;
+chemistry = 3;
+history = 2;
+language = 1;
+total_arrangements = factorial(4)*factorial(maths)*factorial(chemistry)*factorial(history)*factorial(language);
+disp(total_arrangements, "The total number of possible arrangements is ")
\ No newline at end of file diff --git a/291/CH3/EX3.5c/eg3_5c.sce b/291/CH3/EX3.5c/eg3_5c.sce new file mode 100755 index 000000000..522a97855 --- /dev/null +++ b/291/CH3/EX3.5c/eg3_5c.sce @@ -0,0 +1,6 @@ +men = 6;
+women = 4;
+disp(factorial(men+women), "No of different rankings possible is")
+women_top4 = factorial(women)*factorial(men);
+prob = women_top4/factorial(men+women);
+disp(prob, "Probability that women receive the top 4 scores is")
\ No newline at end of file diff --git a/291/CH3/EX3.5d/eg3_5d.sce b/291/CH3/EX3.5d/eg3_5d.sce new file mode 100755 index 000000000..fc6b7a990 --- /dev/null +++ b/291/CH3/EX3.5d/eg3_5d.sce @@ -0,0 +1,7 @@ +men = 6;
+women = 9;
+reqd_size =5;
+total =factorial(men+women)/(factorial(reqd_size)*factorial(men+women-reqd_size));
+given_committee = factorial(men)*factorial(women)/(factorial(3)*factorial(2)*factorial(men-3)*factorial(women-2));
+prob = given_committee/total;
+disp(prob, "Probability that the committee consists of 3 men and 2 women is")
\ No newline at end of file diff --git a/291/CH3/EX3.5f/eg3_5f.sce b/291/CH3/EX3.5f/eg3_5f.sce new file mode 100755 index 000000000..d7f727210 --- /dev/null +++ b/291/CH3/EX3.5f/eg3_5f.sce @@ -0,0 +1,30 @@ +black_p = 6;
+white_p = 6;
+pair = 2;
+total_p = black_p + white_p;
+
+
+
+
+total_pairs = 1;
+while(total_p >0)
+ total_pairs = total_pairs*factorial(total_p)/(factorial(pair) * factorial(total_p - pair) );
+ total_p = total_p -2;
+ //disp(total_pairs)
+end
+//disp(total_pairs)
+total_pairs= total_pairs/factorial(6);
+black_pairs = 1;
+while(black_p >0)
+ black_pairs = black_pairs*factorial(black_p)/((factorial(pair) * factorial(black_p - pair) ));
+ black_p = black_p -2;
+ //disp(black_pairs)
+end
+black_pairs= black_pairs/factorial(3);
+//disp(black_pairs)
+
+
+white_pairs = black_pairs;
+allowed_pairs = black_pairs * white_pairs;
+probb = allowed_pairs/ total_pairs;
+disp(probb, " Probability that a random pairing will not result in any of the white and black players rooming together is ")
\ No newline at end of file diff --git a/291/CH3/EX3.6a/eg3_6a.sce b/291/CH3/EX3.6a/eg3_6a.sce new file mode 100755 index 000000000..9add0151b --- /dev/null +++ b/291/CH3/EX3.6a/eg3_6a.sce @@ -0,0 +1,4 @@ +defective =5;
+partially_defective = 10;
+acceptable = 25;
+disp(acceptable/(acceptable+partially_defective), "The required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.6b/eg3_6b.sce b/291/CH3/EX3.6b/eg3_6b.sce new file mode 100755 index 000000000..cac6321e5 --- /dev/null +++ b/291/CH3/EX3.6b/eg3_6b.sce @@ -0,0 +1,5 @@ +prob_bb = 0.25;
+prob_bg = 0.25;
+prob_gb = 0.25;
+prob_gg = 0.25;
+disp(prob_bb/(prob_bg+prob_gb+prob_bb), "Probability that both are boys is")
\ No newline at end of file diff --git a/291/CH3/EX3.6c/eg3_6c.sce b/291/CH3/EX3.6c/eg3_6c.sce new file mode 100755 index 000000000..0afa95cfd --- /dev/null +++ b/291/CH3/EX3.6c/eg3_6c.sce @@ -0,0 +1,3 @@ +prob_phoenix = 0.3;
+prob_manager = 0.6;
+disp(prob_phoenix*prob_manager , "Probability that Perez will be a Phoenix branch office manager is")
\ No newline at end of file diff --git a/291/CH3/EX3.7a/eg3_7a.sce b/291/CH3/EX3.7a/eg3_7a.sce new file mode 100755 index 000000000..aace4beb7 --- /dev/null +++ b/291/CH3/EX3.7a/eg3_7a.sce @@ -0,0 +1,5 @@ +accident_prone= 0.4;
+nonaccident_prone= 0.2;
+pop_accident = 0.3;
+prob = pop_accident*accident_prone + (1-pop_accident)*nonaccident_prone;
+disp(prob, "The required probability is ");
\ No newline at end of file diff --git a/291/CH3/EX3.7b/eg3_7b.sce b/291/CH3/EX3.7b/eg3_7b.sce new file mode 100755 index 000000000..e97c869c4 --- /dev/null +++ b/291/CH3/EX3.7b/eg3_7b.sce @@ -0,0 +1,6 @@ +accident_prone= 0.4;
+nonaccident_prone= 0.2;
+pop_accident = 0.3;
+prob_of_accident = pop_accident*accident_prone + (1-pop_accident)*nonaccident_prone;
+prob = pop_accident * accident_prone /prob_of_accident;
+disp(prob, "The required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.7c/eg3_7c.sce b/291/CH3/EX3.7c/eg3_7c.sce new file mode 100755 index 000000000..ea129f90d --- /dev/null +++ b/291/CH3/EX3.7c/eg3_7c.sce @@ -0,0 +1,3 @@ +m = 5;
+p =1/2;
+disp( (m*p)/(1+((m-1)*p)), "The required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.7d/eg3_7d.sce b/291/CH3/EX3.7d/eg3_7d.sce new file mode 100755 index 000000000..90937bb5e --- /dev/null +++ b/291/CH3/EX3.7d/eg3_7d.sce @@ -0,0 +1,5 @@ +detect_present = 0.99;
+detect_notpresent = 0.01;
+pop_disease = 0.005;
+prob = detect_present*pop_disease/((detect_present*pop_disease) +(detect_notpresent*(1-pop_disease)) ) ;
+disp(prob, "The required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.7e/eg3_7e.sce b/291/CH3/EX3.7e/eg3_7e.sce new file mode 100755 index 000000000..b63bebc96 --- /dev/null +++ b/291/CH3/EX3.7e/eg3_7e.sce @@ -0,0 +1,5 @@ +criminal_char = 0.9
+convinced= 0.6;
+pop_char = 0.2;
+prob = (convinced*criminal_char) /((convinced*criminal_char) + (pop_char*(1-convinced)));
+disp(prob, "The required probability is")
\ No newline at end of file diff --git a/291/CH3/EX3.7f/eg3_7f.sce b/291/CH3/EX3.7f/eg3_7f.sce new file mode 100755 index 000000000..6063f2727 --- /dev/null +++ b/291/CH3/EX3.7f/eg3_7f.sce @@ -0,0 +1,8 @@ +alpha1 = 0.4;
+plane_in_region1 = 1/3;
+plane_in_region2 = 1/3;
+plane_in_region3 = 1/3;
+prob1 = (alpha1*plane_in_region1)/((alpha1*plane_in_region1)+ 1*plane_in_region2 + 1*plane_in_region3);
+prob2 = (1*plane_in_region2)/((alpha1*plane_in_region1)+ 1*plane_in_region2 + 1*plane_in_region3);
+disp(prob1 , "The probability that the planes is in region 1 given that the search of region 1 did not uncover it ");
+disp(prob2 , "The probability that the planes is in region 2/3 given that the search of region 1 did not uncover it ");
\ No newline at end of file diff --git a/291/CH3/EX3.8a/eg3_8a.sce b/291/CH3/EX3.8a/eg3_8a.sce new file mode 100755 index 000000000..8dc33d834 --- /dev/null +++ b/291/CH3/EX3.8a/eg3_8a.sce @@ -0,0 +1,3 @@ +prob_A = 4/52;
+prob_H = 13/52;
+disp(prob_A*prob_H , "P(AH) is")
\ No newline at end of file diff --git a/291/CH4/EX4.1a/eg4_1a.sce b/291/CH4/EX4.1a/eg4_1a.sce new file mode 100755 index 000000000..aa294a0fc --- /dev/null +++ b/291/CH4/EX4.1a/eg4_1a.sce @@ -0,0 +1,47 @@ +p11 = 1/36;
+p12 = 1/36;
+p13 = 1/36;
+p14 = 1/36;
+p15 = 1/36;
+p16 = 1/36;
+p21 = 1/36;
+p22 = 1/36;
+p23 = 1/36;
+p24 = 1/36;
+p25 = 1/36;
+p26 = 1/36;
+p31 = 1/36;
+p32 = 1/36;
+p33 = 1/36;
+p34 = 1/36;
+p35 = 1/36;
+p36 = 1/36;
+p41 = 1/36;
+p42 = 1/36;
+p43 = 1/36;
+p44 = 1/36;
+p45 = 1/36;
+p46 = 1/36;
+p51 = 1/36;
+p52 = 1/36;
+p53 = 1/36;
+p54 = 1/36;
+p55 = 1/36;
+p56 = 1/36;
+p61 = 1/36;
+p62 = 1/36;
+p63 = 1/36;
+p64 = 1/36;
+p65 = 1/36;
+p66 = 1/36;
+disp(p11, "Probability that the sum is 2")
+disp(p12+p21, "Probability that the sum is 3")
+disp(p13+p31+p22, "Probability that the sum is 4")
+disp(p14+p41+p32+p23, "Probability that the sum is 5")
+disp(p15+p51+p24+p42+p33, "Probability that the sum is 6")
+disp(p16+p61+p25+p52+p34+p43, "Probability that the sum is 7")
+disp(p26+p62+p35+p53+p44, "Probability that the sum is 8")
+disp(p36+p63+p45+p54, "Probability that the sum is 9")
+disp(p46+p64+p55, "Probability that the sum is 10")
+disp(p65+p56, "Probability that the sum is 11")
+disp(p66, "Probability that the sum is 12")
diff --git a/291/CH4/EX4.1b/eg4_1b.sce b/291/CH4/EX4.1b/eg4_1b.sce new file mode 100755 index 000000000..e1d2e8cd4 --- /dev/null +++ b/291/CH4/EX4.1b/eg4_1b.sce @@ -0,0 +1,11 @@ +pdd= 0.09;
+pda = 0.21;
+pad = 0.21;
+paa = 0.49;
+
+disp(pdd, "Probability that the number of acceptable components is 0 is")
+disp(pda+pad, "Probability that the number of acceptable components is 1 is")
+disp(paa, "Probability that the number of acceptable components is 2 is")
+disp(pdd, "Probability that I is 0 is")
+
+disp(paa+pad+pda, "Probability that I is 1 is")
\ No newline at end of file diff --git a/291/CH4/EX4.1c/eg4_1c.sce b/291/CH4/EX4.1c/eg4_1c.sce new file mode 100755 index 000000000..921c2bd00 --- /dev/null +++ b/291/CH4/EX4.1c/eg4_1c.sce @@ -0,0 +1,2 @@ +prob = 1-(1-(1/%e));
+disp( prob, "Probability that X exceeds 1 is")
\ No newline at end of file diff --git a/291/CH4/EX4.2a/eg4_2a.sce b/291/CH4/EX4.2a/eg4_2a.sce new file mode 100755 index 000000000..804e46b4c --- /dev/null +++ b/291/CH4/EX4.2a/eg4_2a.sce @@ -0,0 +1,3 @@ +p1 = 1/2;
+p2 = 1/3;
+disp (1-(p1+p2), "Probability that X is 3 is ")
\ No newline at end of file diff --git a/291/CH4/EX4.2b/eg4_2b.sce b/291/CH4/EX4.2b/eg4_2b.sce new file mode 100755 index 000000000..cddf29538 --- /dev/null +++ b/291/CH4/EX4.2b/eg4_2b.sce @@ -0,0 +1,6 @@ +
+integral = integrate('(4*x)-(2*x*x)' , 'x', 0, 2);
+C = 1/integral;
+disp(C, "The value of C is")
+integral_new = integrate('C*((4*x)-(2*x*x))' , 'x', 0, 1);
+disp(1-integral_new , "Probability that X is greater than 1 is")
\ No newline at end of file diff --git a/291/CH4/EX4.3a/eg4_3a.sce b/291/CH4/EX4.3a/eg4_3a.sce new file mode 100755 index 000000000..0ab26bc52 --- /dev/null +++ b/291/CH4/EX4.3a/eg4_3a.sce @@ -0,0 +1,14 @@ +new = 3;
+working = 4;
+defective =5;
+total = factorial(12)/(factorial(3)*factorial(9));
+disp(factorial(5)/(factorial(3)*factorial(2)*total), "Probability that X=0 and Y=0");
+disp(factorial(5)*factorial(4)/(factorial(3)*factorial(2)*factorial(3)*total), "Probability that X=0 and Y=1");
+disp(factorial(5)*factorial(4)/(factorial(2)*factorial(2)*factorial(4)*total), "Probability that X=0 and Y=2");
+disp(factorial(4)/(factorial(3)*factorial(1)*total), "Probability that X=0 and Y=3");
+disp(factorial(3)*factorial(5)/(factorial(2)*factorial(2)*factorial(3)*total), "Probability that X=1 and Y=0");
+disp(factorial(5)*factorial(4)*factorial(3)/(factorial(2)*factorial(3)*factorial(4)*total), "Probability that X=1 and Y=1");
+disp(factorial(3)*factorial(4)/(factorial(2)*factorial(2)*factorial(2)*total), "Probability that X=1 and Y=2");
+disp(factorial(3)*factorial(5)/(factorial(2)*factorial(4)*factorial(1)*total), "Probability that X=2 and Y=0");
+disp(factorial(3)*factorial(4)/(factorial(2)*factorial(1)*factorial(3)*total), "Probability that X=2 and Y=1");
+disp(factorial(3)/(factorial(3)*total), "Probability that X=3 and Y=3");
\ No newline at end of file diff --git a/291/CH4/EX4.3b/eg4_3b.sce b/291/CH4/EX4.3b/eg4_3b.sce new file mode 100755 index 000000000..d7240828d --- /dev/null +++ b/291/CH4/EX4.3b/eg4_3b.sce @@ -0,0 +1,17 @@ +child0 = 0.15;
+child1 = 0.2;
+child2 = 0.35;
+child3 = 0.30;
+pboy = 0.5;
+pgirl = 0.5;
+
+disp(child0 , "Probability that B=0 and G=0")
+disp(child1*pgirl , "Probability that B=0 and G=1")
+disp(child2*pgirl*pgirl , "Probability that B=0 and G=2")
+disp(child3*pgirl*pgirl*pgirl , "Probability that B=0 and G=3")
+disp(child1*pboy , "Probability that B=1 and G=0")
+disp(child2*pgirl*pboy , "Probability that B=1 and G=1")
+disp(child3*pgirl*pgirl*pboy , "Probability that B=1 and G=2")
+disp(child2*pboy*pboy , "Probability that B=2 and G=0")
+disp(child3*pgirl*pboy*pboy , "Probability that B=2 and G=1")
+disp(child3*pboy*pboy*pboy , "Probability that B=3 and G=0")
diff --git a/291/CH4/EX4.3c/eg4_3c.sce b/291/CH4/EX4.3c/eg4_3c.sce new file mode 100755 index 000000000..01a8b747c --- /dev/null +++ b/291/CH4/EX4.3c/eg4_3c.sce @@ -0,0 +1,6 @@ +intx= integrate('%e^(-x)', 'x',0, 1 );
+inty=integrate('2*%e^(-2*y)', 'y', 0, 1);
+answer = (1-intx)*inty;
+disp(answer , "Probability that X>1 and Y<1 is")
+
+//For other two parts, symbolic manipulations are required
\ No newline at end of file diff --git a/291/CH4/EX4.3e/eg4_3e.sce b/291/CH4/EX4.3e/eg4_3e.sce new file mode 100755 index 000000000..ce0daaa3c --- /dev/null +++ b/291/CH4/EX4.3e/eg4_3e.sce @@ -0,0 +1,8 @@ +pdec3 = 0.05;
+pdec2= 0.1;
+pdec1 = 0.2;
+p0= 0.3
+pinc1= 0.2;
+pinc2= 0.1;
+pinc3 = 0.05;
+disp(pinc1*pinc2*p0, "Probability that the stock price will increase successively by 1, 2 and 0 points in the next 3 days is")
\ No newline at end of file diff --git a/291/CH4/EX4.3f/eg4_3f.sce b/291/CH4/EX4.3f/eg4_3f.sce new file mode 100755 index 000000000..a71d15612 --- /dev/null +++ b/291/CH4/EX4.3f/eg4_3f.sce @@ -0,0 +1,5 @@ +disp(0.1/0.3875, "probability that B =0 given G=1 ");
+disp(0.175/0.3875, "probability that B =1 given G=1 ");
+disp(0.1125/0.3875, "probability that B =2 given G=1 ");
+disp(0/0.3875, "probability that B =3 given G=1 ");
+//The values are taken from Table 4.2
\ No newline at end of file diff --git a/291/CH4/EX4.3g/eg4_3g.sce b/291/CH4/EX4.3g/eg4_3g.sce new file mode 100755 index 000000000..65839531a --- /dev/null +++ b/291/CH4/EX4.3g/eg4_3g.sce @@ -0,0 +1,8 @@ +p00=0.4;
+p01 = 0.2;
+p10 = 0.1;
+p11= 0.3;
+
+pY1= p01+p11;
+disp(p01/pY1, "Probability that X=0 and Y=1")
+disp(p11/pY1, "Probability that X=1 and Y=1")
\ No newline at end of file diff --git a/291/CH4/EX4.4a/eg4_4a.sce b/291/CH4/EX4.4a/eg4_4a.sce new file mode 100755 index 000000000..03e3cb541 --- /dev/null +++ b/291/CH4/EX4.4a/eg4_4a.sce @@ -0,0 +1,8 @@ +p1=1/6;
+p2=1/6;
+p3=1/6;
+p4=1/6;
+p5=1/6;
+p6=1/6;
+expec= p1 + (2*p2)+(3*p3)+(4*p4)+(5*p5)+ (6*p6);
+disp(expec)
\ No newline at end of file diff --git a/291/CH4/EX4.4d/eg4_4d.sce b/291/CH4/EX4.4d/eg4_4d.sce new file mode 100755 index 000000000..fa8bee4ef --- /dev/null +++ b/291/CH4/EX4.4d/eg4_4d.sce @@ -0,0 +1,2 @@ +expec= integrate('(x)/1.5', 'x', 0,1.5);
+disp("hours", expec, "On an average, you have to wait for ")
\ No newline at end of file diff --git a/291/CH4/EX4.5a/eg4_5a.sce b/291/CH4/EX4.5a/eg4_5a.sce new file mode 100755 index 000000000..4857aff36 --- /dev/null +++ b/291/CH4/EX4.5a/eg4_5a.sce @@ -0,0 +1,5 @@ +p0= 0.2;
+p1= 0.5;
+p2=0.3;
+expec = 0*0*p0 + 1*1*p1 + 2*2*p2;
+disp(expec, "Expectation of X^2 is")
\ No newline at end of file diff --git a/291/CH4/EX4.5b/eg4_5b.sce b/291/CH4/EX4.5b/eg4_5b.sce new file mode 100755 index 000000000..a2bbb5766 --- /dev/null +++ b/291/CH4/EX4.5b/eg4_5b.sce @@ -0,0 +1,2 @@ +expec = integrate('x^3', 'x', 0, 1);
+disp(expec, "The expectation is")
\ No newline at end of file diff --git a/291/CH4/EX4.5c/eg4_5c.sce b/291/CH4/EX4.5c/eg4_5c.sce new file mode 100755 index 000000000..4857aff36 --- /dev/null +++ b/291/CH4/EX4.5c/eg4_5c.sce @@ -0,0 +1,5 @@ +p0= 0.2;
+p1= 0.5;
+p2=0.3;
+expec = 0*0*p0 + 1*1*p1 + 2*2*p2;
+disp(expec, "Expectation of X^2 is")
\ No newline at end of file diff --git a/291/CH4/EX4.5d/eg4_5d.sce b/291/CH4/EX4.5d/eg4_5d.sce new file mode 100755 index 000000000..a2bbb5766 --- /dev/null +++ b/291/CH4/EX4.5d/eg4_5d.sce @@ -0,0 +1,2 @@ +expec = integrate('x^3', 'x', 0, 1);
+disp(expec, "The expectation is")
\ No newline at end of file diff --git a/291/CH4/EX4.5e/eg4_5e.sce b/291/CH4/EX4.5e/eg4_5e.sce new file mode 100755 index 000000000..066e1d0c5 --- /dev/null +++ b/291/CH4/EX4.5e/eg4_5e.sce @@ -0,0 +1,8 @@ +profit1 = 10;
+profit2= 20;
+profit3 = 40;
+prob1= 0.2;
+prob2 = 0.8;
+prob3 = 0.3;
+expec = profit1*prob1 + profit2*prob2 + profit3*prob3;
+disp(" thousand dollars", expec, "The expectd profit is")
\ No newline at end of file diff --git a/291/CH4/EX4.5f/eg4_5f.sce b/291/CH4/EX4.5f/eg4_5f.sce new file mode 100755 index 000000000..afda4e253 --- /dev/null +++ b/291/CH4/EX4.5f/eg4_5f.sce @@ -0,0 +1,9 @@ +//As scilab does not symbolic computations, this example is solved taking N=5
+prob = 1/5 //probability that a letter is put into the right envelope
+EX1 = 1*prob+0*(1-prob);
+EX2 = 1*prob+0*(1-prob);
+EX3 = 1*prob+0*(1-prob);
+EX4 = 1*prob+0*(1-prob);
+EX5 = 1*prob+0*(1-prob);
+EX= EX1 + EX2+ EX3 +EX4 + EX5;
+disp(EX, "Thus, the expectation is")
\ No newline at end of file diff --git a/291/CH4/EX4.5g/eg4_5g.sce b/291/CH4/EX4.5g/eg4_5g.sce new file mode 100755 index 000000000..95f6ce8ef --- /dev/null +++ b/291/CH4/EX4.5g/eg4_5g.sce @@ -0,0 +1,4 @@ +ProbXiequals1 = 1 - ((19/20)^10);
+EXi = ProbXiequals1 ;
+EX = 20*EXi;
+disp(EX, "The expectation is")
\ No newline at end of file diff --git a/291/CH4/EX4.6a/eg4_6a.sce b/291/CH4/EX4.6a/eg4_6a.sce new file mode 100755 index 000000000..590bd709c --- /dev/null +++ b/291/CH4/EX4.6a/eg4_6a.sce @@ -0,0 +1,9 @@ +probXequalsi = 1/6;
+expecXsquared = 0;
+for n=1:6
+ expecXsquared = expecXsquared + (n*n*probXequalsi)
+end
+
+expecX= 3.5 // from eg 4.4a
+var = expecXsquared - (expecX^2);
+disp(var, "The variance is")
diff --git a/291/CH4/EX4.7a/eg4_7a.sce b/291/CH4/EX4.7a/eg4_7a.sce new file mode 100755 index 000000000..98f73141a --- /dev/null +++ b/291/CH4/EX4.7a/eg4_7a.sce @@ -0,0 +1,10 @@ +probXequalsi = 1/6;
+expecXsquared = 0;
+for n=1:6
+ expecXsquared = expecXsquared + (n*n*probXequalsi)
+end
+
+expecX= 3.5 // from eg 4.4a
+var = expecXsquared - (expecX^2);
+var10 = var*10;
+disp(var10, "The variance is")
\ No newline at end of file diff --git a/291/CH4/EX4.7b/eg4_7b.sce b/291/CH4/EX4.7b/eg4_7b.sce new file mode 100755 index 000000000..28d3932df --- /dev/null +++ b/291/CH4/EX4.7b/eg4_7b.sce @@ -0,0 +1,4 @@ +probIj = 0.5;
+varIj = probIj*(1-probIj);
+var = 10*varIj;
+disp(var, "Thus, the required variance is")
\ No newline at end of file diff --git a/291/CH4/EX4.9a/eg4_9a.sce b/291/CH4/EX4.9a/eg4_9a.sce new file mode 100755 index 000000000..05efdc7e4 --- /dev/null +++ b/291/CH4/EX4.9a/eg4_9a.sce @@ -0,0 +1,6 @@ +avg = 50;
+probX75 = avg/75;
+disp(probX75, "Probability that X>75 is")
+var = 25;
+upperlimit = var/100;
+disp(1-upperlimit, "Probability that X lies between 40 and 60 is")
\ No newline at end of file diff --git a/291/CH5/EX5.1a/eg5_1a.sce b/291/CH5/EX5.1a/eg5_1a.sce new file mode 100755 index 000000000..b7e3c6cb5 --- /dev/null +++ b/291/CH5/EX5.1a/eg5_1a.sce @@ -0,0 +1,11 @@ +defects= 0.01;
+disks = 10;
+package = 3;
+probdefect0 = ((1-defects)^10);
+probdefect1 = factorial(disks)*defects*((1-defects)^9)/factorial(disks-1);
+prob = 1 - probdefect0 -probdefect1;
+disp(prob, "Probability that a package will be returned is")
+newprob = factorial(package)*prob*((1-prob)^2)/factorial(package-1);
+disp(newprob, "Probability that exactly one of the packages will be returned among 3 is" )
+
+//the solution in the textbook is approximate
\ No newline at end of file diff --git a/291/CH5/EX5.1b/eg5_1b.sce b/291/CH5/EX5.1b/eg5_1b.sce new file mode 100755 index 000000000..61ed1264a --- /dev/null +++ b/291/CH5/EX5.1b/eg5_1b.sce @@ -0,0 +1,9 @@ +function result= binomial(n, k, p)
+ result = factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k))
+endfunction
+
+children = 4;
+reqdblueyes = 2;
+probblueeyes = 0.5*0.5;
+prob = binomial(children, reqdblueyes, probblueeyes);
+disp(prob, "The reqd probability is")
\ No newline at end of file diff --git a/291/CH5/EX5.1e/eg5_1e.sce b/291/CH5/EX5.1e/eg5_1e.sce new file mode 100755 index 000000000..1830cd399 --- /dev/null +++ b/291/CH5/EX5.1e/eg5_1e.sce @@ -0,0 +1,15 @@ +function result=bin(n,k, p)
+ if(k==0)
+ result = (1-p)^n;
+ else
+ result = p*(n-k+1)*bin(n, k-1, p)/((1-p)*k);
+ end
+endfunction
+
+disp(bin(6, 0, 0.4), "Probability that X=0 is")
+disp(bin(6, 1, 0.4), "Probability that X=1 is")
+disp(bin(6, 2, 0.4), "Probability that X=2 is")
+disp(bin(6, 3, 0.4), "Probability that X=3 is")
+disp(bin(6, 4, 0.4), "Probability that X=4 is")
+disp(bin(6, 5, 0.4), "Probability that X=5 is")
+disp(bin(6, 6, 0.4), "Probability that X=6 is")
\ No newline at end of file diff --git a/291/CH5/EX5.2a/eg5_2a.sce b/291/CH5/EX5.2a/eg5_2a.sce new file mode 100755 index 000000000..60a5d4861 --- /dev/null +++ b/291/CH5/EX5.2a/eg5_2a.sce @@ -0,0 +1,3 @@ +[probX0, Q]= cdfpoi("PQ", 0, 3);
+probX1 = 1- probX0;
+disp(probX1, "Probability that there is at least one accident this week is ")
\ No newline at end of file diff --git a/291/CH5/EX5.2b/eg5_2b.sce b/291/CH5/EX5.2b/eg5_2b.sce new file mode 100755 index 000000000..4d43b219d --- /dev/null +++ b/291/CH5/EX5.2b/eg5_2b.sce @@ -0,0 +1,9 @@ +function result= bino(n, k, p)
+ result = factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k))
+endfunction
+
+prob = bino(10,0, 0.1) + bino(10, 1,0.1 );
+disp(prob, "The exact probability is ");
+
+probp = cdfpoi("PQ", 1, 1)
+disp(probp, "The poisson approximation is ")
\ No newline at end of file diff --git a/291/CH5/EX5.2c/eg5_2c.sce b/291/CH5/EX5.2c/eg5_2c.sce new file mode 100755 index 000000000..024de4310 --- /dev/null +++ b/291/CH5/EX5.2c/eg5_2c.sce @@ -0,0 +1,4 @@ +Xlam = 3.2;
+i =2;
+prob = cdfpoi("PQ", i, Xlam);
+disp(prob)
\ No newline at end of file diff --git a/291/CH5/EX5.2d/eg5_2d.sce b/291/CH5/EX5.2d/eg5_2d.sce new file mode 100755 index 000000000..4246773f1 --- /dev/null +++ b/291/CH5/EX5.2d/eg5_2d.sce @@ -0,0 +1,11 @@ +function result= bino(n, k, p)
+ result = factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k))
+endfunction
+avg = 5;
+i=3;
+prob = cdfpoi("PQ", 2, avg);
+disp(prob, "Proportion of days that have less than 3 claims is")
+probX4 = cdfpoi("PQ",i+1, avg) - cdfpoi("PQ", i, avg);
+
+reqdprob = bino(5,3 , probX4);
+disp(reqdprob, "Probability that 3 of the next 5 days will have exactly 4 claims is ")
\ No newline at end of file diff --git a/291/CH5/EX5.2f/eg5_2f.sce b/291/CH5/EX5.2f/eg5_2f.sce new file mode 100755 index 000000000..b77d31a8b --- /dev/null +++ b/291/CH5/EX5.2f/eg5_2f.sce @@ -0,0 +1,3 @@ +avg = 4;
+prob = cdfpoi("PQ", 3, 2*avg)
+disp(prob)
\ No newline at end of file diff --git a/291/CH5/EX5.3a/eg5_3a.sce b/291/CH5/EX5.3a/eg5_3a.sce new file mode 100755 index 000000000..e7880aab0 --- /dev/null +++ b/291/CH5/EX5.3a/eg5_3a.sce @@ -0,0 +1,6 @@ +function result= hyper(N, M, n, i)
+ result = factorial(N)*factorial(M)*factorial(n)*factorial(N+M-n)/(factorial(i)*factorial(N-i)*factorial(n-i)*factorial(M-n+i)*factorial(N+M));
+endfunction
+
+prob = hyper(15, 5,6, 4)+hyper(15, 5,6,5)+hyper(15,5,6,6);
+disp(prob, "Probability that the system will be functional is")
\ No newline at end of file diff --git a/291/CH5/EX5.3b/eg5_3b.sce b/291/CH5/EX5.3b/eg5_3b.sce new file mode 100755 index 000000000..ad672f663 --- /dev/null +++ b/291/CH5/EX5.3b/eg5_3b.sce @@ -0,0 +1,8 @@ +function result= hyper(N, M, n, i)
+ result = factorial(N)*factorial(M)*factorial(n)*factorial(N+M-n)/(factorial(i)*factorial(N-i)*factorial(n-i)*factorial(M-n+i)*factorial(N+M));
+endfunction
+
+r= 50;
+n=100;
+X=25;
+disp(r*n/X , "Estimate of the number of animals in the region is")
\ No newline at end of file diff --git a/291/CH5/EX5.3c/eg5_3c.sce b/291/CH5/EX5.3c/eg5_3c.sce new file mode 100755 index 000000000..faa76e531 --- /dev/null +++ b/291/CH5/EX5.3c/eg5_3c.sce @@ -0,0 +1,9 @@ +function result= bino(n, k, p)
+ result = factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k))
+endfunction
+
+function answer= condprob(n,k,p,i)
+ answer = bino(n,i,p)*bino(m,k-i,p)/bino(n+m,k, p);
+endfunction
+
+//The function condprob will give P{X=i|X+Y=k}
\ No newline at end of file diff --git a/291/CH5/EX5.4b/eg5_4b.sce b/291/CH5/EX5.4b/eg5_4b.sce new file mode 100755 index 000000000..c552ea272 --- /dev/null +++ b/291/CH5/EX5.4b/eg5_4b.sce @@ -0,0 +1,5 @@ +pass_f = 1/30;
+prob1 = (15-10)*pass_f + (30-25)*pass_f;
+prob2 = (3-0)*pass_f + (18-15)*pass_f;
+disp(prob1, "Probability that he waits less than 5 minutes for a bus")
+disp(prob2, "Probability that he waits at least 12 minutes for a bus")
\ No newline at end of file diff --git a/291/CH5/EX5.4c/eg5_4c.sce b/291/CH5/EX5.4c/eg5_4c.sce new file mode 100755 index 000000000..82a601ed2 --- /dev/null +++ b/291/CH5/EX5.4c/eg5_4c.sce @@ -0,0 +1,9 @@ +a=5;
+I0=10^-6;
+v_f = 1/(3-1);
+vupperlim = 3;
+vlowerlim = 1;
+expecV = (vupperlim + vlowerlim)/2;
+expec = integrate('(%e^(a*x))/2', 'x', 1,3);
+expecI=I0*(expec -1);
+disp(expecI)
\ No newline at end of file diff --git a/291/CH5/EX5.5a/eg5_5a.sce b/291/CH5/EX5.5a/eg5_5a.sce new file mode 100755 index 000000000..59ce53c5a --- /dev/null +++ b/291/CH5/EX5.5a/eg5_5a.sce @@ -0,0 +1,9 @@ +u= 3;
+var = 16;
+
+prob1 = cdfnor("PQ", 11, u, sqrt(var));
+disp(prob1, " P{X<11}");
+prob2 = 1- cdfnor( "PQ", -1, u, sqrt(var));
+disp(prob2, "P{X>-1}");
+prob3= cdfnor("PQ", 7, u, sqrt(var)) - cdfnor("PQ", 2, u, sqrt(var));
+disp(prob3, "P{2<X<7}");
\ No newline at end of file diff --git a/291/CH5/EX5.5b/eg5_5b.sce b/291/CH5/EX5.5b/eg5_5b.sce new file mode 100755 index 000000000..d1f9174e3 --- /dev/null +++ b/291/CH5/EX5.5b/eg5_5b.sce @@ -0,0 +1,2 @@ +disp(cdfnor("PQ", -1.5, 0, 1), "P{error|message is 1}")
+disp(1-cdfnor("PQ", 2.5, 0, 1), "P{error|message is 0 }")
diff --git a/291/CH5/EX5.5c/eg5_5c.sce b/291/CH5/EX5.5c/eg5_5c.sce new file mode 100755 index 000000000..5b50c756e --- /dev/null +++ b/291/CH5/EX5.5c/eg5_5c.sce @@ -0,0 +1,10 @@ +r =3;
+avg = 6;
+std= 1;
+var = std^2;
+expecV2 = var + (avg^2);
+expecW = 3*expecV2;
+disp(expecW, "Expectation of W is ")
+limw=120;
+limV = sqrt(limw/r);
+disp(1-cdfnor("PQ", limV, avg, std), "P{W>120} is")
\ No newline at end of file diff --git a/291/CH5/EX5.5d/eg5_5d.sce b/291/CH5/EX5.5d/eg5_5d.sce new file mode 100755 index 000000000..b265156b6 --- /dev/null +++ b/291/CH5/EX5.5d/eg5_5d.sce @@ -0,0 +1,11 @@ +meanX1 = 12.08;
+meanX2= 12.08;
+stX1= 3.1;
+meanX = meanX1 + meanX2;
+varX = 2*(3.1^2);
+lim= 25;
+disp(1-cdfnor("PQ", lim, meanX, sqrt(varX)), "Probability that the total precipitation during the next 2 years will exceed 25 inches")
+
+meanXnew= meanX1 - meanX2;
+new_lim= 3;
+disp(1- cdfnor("PQ", new_lim, meanXnew, sqrt(varX)), "Probability that precipitation in the next year will exceed that in the following year by more than 3 inches")
\ No newline at end of file diff --git a/291/CH5/EX5.6a/eg5_6a.sce b/291/CH5/EX5.6a/eg5_6a.sce new file mode 100755 index 000000000..5fb945a6d --- /dev/null +++ b/291/CH5/EX5.6a/eg5_6a.sce @@ -0,0 +1,4 @@ +lamda = 1/10000;
+x = 5000;
+prob = %e^(-1*lamda*x);
+disp(prob, " Probability that she will be able to complete her trip without having to replace her car battery is");
\ No newline at end of file diff --git a/291/CH5/EX5.6b/eg5_6b.sce b/291/CH5/EX5.6b/eg5_6b.sce new file mode 100755 index 000000000..9acfbe2b2 --- /dev/null +++ b/291/CH5/EX5.6b/eg5_6b.sce @@ -0,0 +1,3 @@ +//When C is put to use, one other machine(either A or B ) will still be working . The probability of this machine or C failing is equal due to the memoryless propoerty of exponential random variables.
+
+disp(1/2, "The probability that machine which is still operable is machine C is ")
\ No newline at end of file diff --git a/291/CH5/EX5.6c/eg5_6c.sce b/291/CH5/EX5.6c/eg5_6c.sce new file mode 100755 index 000000000..78edb3d5f --- /dev/null +++ b/291/CH5/EX5.6c/eg5_6c.sce @@ -0,0 +1,7 @@ +function result= new(lamda,n, t )
+ newsum = 0;
+ for i=1:n
+ newsum= newsum + lamda(i)
+ result=%e^(-1*newsum*t)
+ end
+endfunction
\ No newline at end of file diff --git a/291/CH5/EX5.8a/eg5_8a.sce b/291/CH5/EX5.8a/eg5_8a.sce new file mode 100755 index 000000000..6ae56fa15 --- /dev/null +++ b/291/CH5/EX5.8a/eg5_8a.sce @@ -0,0 +1 @@ +disp(cdfchn("PQ", 30, 26, 0));
\ No newline at end of file diff --git a/291/CH5/EX5.8b/eg5_8b.sce b/291/CH5/EX5.8b/eg5_8b.sce new file mode 100755 index 000000000..ceb2cc109 --- /dev/null +++ b/291/CH5/EX5.8b/eg5_8b.sce @@ -0,0 +1 @@ +disp(cdfchn("X", 15, 0,0.95, 0.05 ))
\ No newline at end of file diff --git a/291/CH5/EX5.8c/eg5_8c.sce b/291/CH5/EX5.8c/eg5_8c.sce new file mode 100755 index 000000000..50c34db70 --- /dev/null +++ b/291/CH5/EX5.8c/eg5_8c.sce @@ -0,0 +1 @@ +disp(1- cdfchn("PQ", 9/4, 3, 0))
\ No newline at end of file diff --git a/291/CH5/EX5.8d/eg5_8d.sce b/291/CH5/EX5.8d/eg5_8d.sce new file mode 100755 index 000000000..8f26cdc74 --- /dev/null +++ b/291/CH5/EX5.8d/eg5_8d.sce @@ -0,0 +1 @@ +disp(1- cdfchn("PQ", 2.25,2,0))
\ No newline at end of file diff --git a/291/CH5/EX5.8e/eg5_8e.sce b/291/CH5/EX5.8e/eg5_8e.sce new file mode 100755 index 000000000..ca3e57b39 --- /dev/null +++ b/291/CH5/EX5.8e/eg5_8e.sce @@ -0,0 +1,2 @@ +disp(cdft("PQ", 1.4, 12), "P{T12 <=1.4}");
+disp(cdft("T", 9, 0.975, 0.025), "t0.025, 9")
\ No newline at end of file diff --git a/291/CH5/EX5.8f/eg5_8f.sce b/291/CH5/EX5.8f/eg5_8f.sce new file mode 100755 index 000000000..622413535 --- /dev/null +++ b/291/CH5/EX5.8f/eg5_8f.sce @@ -0,0 +1 @@ +disp(cdff("PQ", 1.5, 6, 14))
\ No newline at end of file diff --git a/291/CH6/EX6.3a/eg6_3a.sce b/291/CH6/EX6.3a/eg6_3a.sce new file mode 100755 index 000000000..14cbaf78e --- /dev/null +++ b/291/CH6/EX6.3a/eg6_3a.sce @@ -0,0 +1,7 @@ +number = 25000;
+meaneach = 320;
+sdeach = 540;
+claim = 8300000;
+meantotal= meaneach*number;
+sdtotal = sdeach*sqrt(number);
+disp(1- cdfnor("PQ",claim, meantotal, sdtotal ))
\ No newline at end of file diff --git a/291/CH6/EX6.3c/eg6_3c.sce b/291/CH6/EX6.3c/eg6_3c.sce new file mode 100755 index 000000000..856c11625 --- /dev/null +++ b/291/CH6/EX6.3c/eg6_3c.sce @@ -0,0 +1,5 @@ +ideal_num = 150;
+actual_num = 450;
+attend = 0.3;
+tolerance = 0.5
+disp(1-cdfnor("PQ",ideal_num+tolerance, actual_num*attend, sqrt(actual_num*attend*(1-attend)) ))
\ No newline at end of file diff --git a/291/CH6/EX6.3d/eg6_3d.sce b/291/CH6/EX6.3d/eg6_3d.sce new file mode 100755 index 000000000..e977e8edc --- /dev/null +++ b/291/CH6/EX6.3d/eg6_3d.sce @@ -0,0 +1,14 @@ +meaneach = 167;
+sdeach = 27;
+num = 36;
+sdtotal = sdeach/sqrt(num);
+//sdtotal = sdtotal*sdtotal;
+//disp(sdtotal)
+disp(cdfnor("PQ", 170, meaneach, sdtotal)-cdfnor("PQ", 163, meaneach,sdtotal ), "Probability that the sample mean of their weights lies between 163 and 170(when sample size is 36)")
+
+num=144;
+sdtotal = sdeach/sqrt(num);
+//disp(sdtotal)
+disp(cdfnor("PQ", 170, meaneach, sdtotal)-cdfnor("PQ", 163, meaneach,sdtotal ), "Probability that the sample mean of their weights lies between 163 and 170(when sample size is 144)")
+
+//The answer given in the textbook is incorrect as (170-167)/4.5 is not equal to 0.6259 .
\ No newline at end of file diff --git a/291/CH6/EX6.3e/eg6_3e.sce b/291/CH6/EX6.3e/eg6_3e.sce new file mode 100755 index 000000000..c6ae2ff4e --- /dev/null +++ b/291/CH6/EX6.3e/eg6_3e.sce @@ -0,0 +1,4 @@ +prob = 0.95;
+lim = 0.5;
+X = cdfnor("X", 0,1, 0.975, 0.025 )
+disp(ceil((4*X)^2), "Observations are necessary (atleast)")
\ No newline at end of file diff --git a/291/CH6/EX6.5a/eg6_5a.sce b/291/CH6/EX6.5a/eg6_5a.sce new file mode 100755 index 000000000..3e878ca57 --- /dev/null +++ b/291/CH6/EX6.5a/eg6_5a.sce @@ -0,0 +1,6 @@ +n= 15;
+sigmasquare= 9;
+lim =12;
+actual_lim = (n-1)*lim/sigmasquare;
+prob = 1- cdfchi("PQ", actual_lim, (n-1))
+disp(prob)
diff --git a/291/CH6/EX6.6a/eg6_6a.sce b/291/CH6/EX6.6a/eg6_6a.sce new file mode 100755 index 000000000..1edeb9987 --- /dev/null +++ b/291/CH6/EX6.6a/eg6_6a.sce @@ -0,0 +1,23 @@ +favour = 0.45;
+samplesize = 200;
+expec= favour*samplesize;
+sd = sqrt(samplesize*favour*(1-favour));
+disp(expec, "The expected value is ")
+disp(sd, "The standard deviation is ")
+
+function result= bino(n, k, p)
+ result = factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k))
+endfunction
+
+//newsum = 0;
+//for i=1:10
+ // newsum = newsum + bino(200,i, favour)
+//end
+//prob = 1-newsum;*/
+
+lim = 101;
+tolerance = 0.5;
+lim= lim - tolerance;
+prob = 1- cdfnor("PQ", lim, expec, sd)
+
+disp(prob, "Probability that more than half the members of the sample favour the candidate")
\ No newline at end of file diff --git a/291/CH6/EX6.6b/eg6_6b.sce b/291/CH6/EX6.6b/eg6_6b.sce new file mode 100755 index 000000000..8a2794ef0 --- /dev/null +++ b/291/CH6/EX6.6b/eg6_6b.sce @@ -0,0 +1,8 @@ +meaneach = 147;
+sdeach = 62;
+samplesize = 25;
+lim =150;
+samplemean = meaneach;
+samplesd= sdeach/sqrt(samplesize)
+prob = 1- cdfnor("PQ", lim, samplemean, samplesd)
+disp(prob)
\ No newline at end of file diff --git a/291/CH7/EX7.2a/eg7_2a.sce b/291/CH7/EX7.2a/eg7_2a.sce new file mode 100755 index 000000000..0c3f3beff --- /dev/null +++ b/291/CH7/EX7.2a/eg7_2a.sce @@ -0,0 +1,3 @@ +samplesize = 1000;
+acceptable =921;
+disp(acceptable/samplesize, "The maximum likelihood estimate of p is")
\ No newline at end of file diff --git a/291/CH7/EX7.2b/eg7_2b.sce b/291/CH7/EX7.2b/eg7_2b.sce new file mode 100755 index 000000000..18bd48ad6 --- /dev/null +++ b/291/CH7/EX7.2b/eg7_2b.sce @@ -0,0 +1,3 @@ +function result= totalerror(n1, n2, n12)
+ result = n1*n2/n12;
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.2c/eg7_2c.sce b/291/CH7/EX7.2c/eg7_2c.sce new file mode 100755 index 000000000..2efab66ea --- /dev/null +++ b/291/CH7/EX7.2c/eg7_2c.sce @@ -0,0 +1,3 @@ +total_people = 857;
+days= 20;
+disp(total_people/days, "The maximum likelihood estimate of lambda")
\ No newline at end of file diff --git a/291/CH7/EX7.2d/eg7_2d.sce b/291/CH7/EX7.2d/eg7_2d.sce new file mode 100755 index 000000000..7c20cb268 --- /dev/null +++ b/291/CH7/EX7.2d/eg7_2d.sce @@ -0,0 +1,3 @@ +accidents= [4 0 6 5 2 1 2 0 4 3 ];
+lambda= mean(accidents)
+disp(cdfpoi("PQ", 2, lambda))
\ No newline at end of file diff --git a/291/CH7/EX7.2e/eg7_2e.sce b/291/CH7/EX7.2e/eg7_2e.sce new file mode 100755 index 000000000..f69401ac4 --- /dev/null +++ b/291/CH7/EX7.2e/eg7_2e.sce @@ -0,0 +1,8 @@ +function[u, sigmasquared]=normal(X, Xmean, n)
+ u= Xmean;
+ newsum = 0;
+ for i= 1:n
+ newsum= newsum + (X(i)-Xmean)^2
+ end
+ sigmasquared = sqrt((newsum/n));
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.2f/eg7_2f.sce b/291/CH7/EX7.2f/eg7_2f.sce new file mode 100755 index 000000000..9df5c4963 --- /dev/null +++ b/291/CH7/EX7.2f/eg7_2f.sce @@ -0,0 +1,13 @@ +X= [2.2 3.4 1.6 0.8 2.7 3.3 1.6 2.8 2.5 1.9]
+upperlimX = 3
+lowerlimX = 2;
+upperlimlogX= log(upperlimX);
+lowerlimlogX = log(lowerlimX);
+
+logX = log(X)
+samplemean= mean(logX)
+samplesd= sqrt(variance(logX))
+//disp(samplemean)
+//disp(samplesd)
+prob = cdfnor("PQ", upperlimlogX, samplemean, samplesd) - cdfnor("PQ", lowerlimlogX, samplemean, samplesd)
+disp(prob)
\ No newline at end of file diff --git a/291/CH7/EX7.2g/eg7_2g.sce b/291/CH7/EX7.2g/eg7_2g.sce new file mode 100755 index 000000000..f234318d7 --- /dev/null +++ b/291/CH7/EX7.2g/eg7_2g.sce @@ -0,0 +1,3 @@ +function result= unif(X, n)
+ result = max(X)/2;
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.3a/eg7_3a.sce b/291/CH7/EX7.3a/eg7_3a.sce new file mode 100755 index 000000000..b4d44a102 --- /dev/null +++ b/291/CH7/EX7.3a/eg7_3a.sce @@ -0,0 +1,9 @@ +avg = 0;
+var = 4;
+num = 9;
+X =[5 8.5 12 15 7 9 7.5 6.5 10.5];
+samplemean= mean(X);
+lowerlim = samplemean - (1.96*sqrt(var/num))
+upperlim = samplemean + (1.96*sqrt(var/num))
+
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is ", )
\ No newline at end of file diff --git a/291/CH7/EX7.3b/eg7_3b.sce b/291/CH7/EX7.3b/eg7_3b.sce new file mode 100755 index 000000000..b15d33bce --- /dev/null +++ b/291/CH7/EX7.3b/eg7_3b.sce @@ -0,0 +1,10 @@ +avg = 0;
+var = 4;
+num = 9;
+X =[5 8.5 12 15 7 9 7.5 6.5 10.5];
+samplemean= mean(X);
+lowerlim = samplemean - (1.645*sqrt(var/num))
+upperlim = samplemean + (1.645*sqrt(var/num))
+
+disp(" to infinity", lowerlim,"The 95% upper confidence interval is " )
+disp(upperlim,"The 95% upper confidence interval is minus infinity to " )
\ No newline at end of file diff --git a/291/CH7/EX7.3c/eg7_3c.sce b/291/CH7/EX7.3c/eg7_3c.sce new file mode 100755 index 000000000..7d4c685ee --- /dev/null +++ b/291/CH7/EX7.3c/eg7_3c.sce @@ -0,0 +1,17 @@ +var = 4;
+num = 9;
+X =[5 8.5 12 15 7 9 7.5 6.5 10.5];
+samplemean= mean(X);
+alpha= 0.005;
+zalpha = cdfnor("X", 0, 1,1-alpha ,alpha);
+//disp(zalpha)
+lowerlim = samplemean - (zalpha*sqrt(var/num))
+upperlim = samplemean + (zalpha*sqrt(var/num))
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is ", )
+
+alpha= 0.01;
+zalpha = cdfnor("X", 0, 1,1-alpha ,alpha);
+lowerlim = samplemean - (zalpha*sqrt(var/num))
+upperlim = samplemean + (zalpha*sqrt(var/num))
+disp(" to infinity", lowerlim,"The 95% upper confidence interval is " )
+disp(upperlim,"The 95% upper confidence interval is minus infinity to " )
\ No newline at end of file diff --git a/291/CH7/EX7.3d/eg7_3d.sce b/291/CH7/EX7.3d/eg7_3d.sce new file mode 100755 index 000000000..7cde3a524 --- /dev/null +++ b/291/CH7/EX7.3d/eg7_3d.sce @@ -0,0 +1,4 @@ +sd= 0.3;
+lim = 0.1;
+num = (1.96*sd/lim)^2;
+disp(num, "Sample size should be greater than");
\ No newline at end of file diff --git a/291/CH7/EX7.3e/eg7_3e.sce b/291/CH7/EX7.3e/eg7_3e.sce new file mode 100755 index 000000000..228553d50 --- /dev/null +++ b/291/CH7/EX7.3e/eg7_3e.sce @@ -0,0 +1,11 @@ +X = [5 8.5 12 15 7 9 7.5 6.5 10.5];
+num = 9;
+meanX= mean(X);
+X2 = X^2;
+s2= (sum(X2)- (num*(meanX^2)))/(num-1);
+s= sqrt(s2);
+tval = cdft("T", num-1, 0.975, 0.025);
+//disp(tval)
+upperlim = meanX + (tval*s)/sqrt(num);
+lowerlim = meanX - (tval*s)/sqrt(num);
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is ", )
\ No newline at end of file diff --git a/291/CH7/EX7.3f/eg7_3f.sce b/291/CH7/EX7.3f/eg7_3f.sce new file mode 100755 index 000000000..715900e0b --- /dev/null +++ b/291/CH7/EX7.3f/eg7_3f.sce @@ -0,0 +1,15 @@ +X = [54 63 58 72 49 92 70 73 69 104 48 66 80 64 77];
+num = 15;
+meanX= mean(X);
+X2 = X^2;
+s2= (sum(X2)- (num*(meanX^2)))/(num-1);
+s= sqrt(s2);
+tval = cdft("T", num-1, 0.975, 0.025);
+//disp(tval)
+upperlim = meanX + (tval*s)/sqrt(num);
+lowerlim = meanX - (tval*s)/sqrt(num);
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is ", )
+alpha = 0.05;
+tval = cdft("T", num-1, 1-alpha, alpha);
+lim = meanX + (tval*s)/sqrt(num);
+disp(lim, "The 95% lower confidence interval is from minus infinity to ")
\ No newline at end of file diff --git a/291/CH7/EX7.3g/eg7_3g.sce b/291/CH7/EX7.3g/eg7_3g.sce new file mode 100755 index 000000000..a40c8dbaa --- /dev/null +++ b/291/CH7/EX7.3g/eg7_3g.sce @@ -0,0 +1,8 @@ +meanX = 0.786;
+s= 0.03;
+num = 100;
+alpha = 0.05;
+tval = cdft("T", num-1, 1-alpha, alpha);
+upperlim = meanX + (tval*s)/sqrt(num);
+lowerlim = meanX - (tval*s)/sqrt(num);
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is ", )
\ No newline at end of file diff --git a/291/CH7/EX7.3h/eg7_3h.sce b/291/CH7/EX7.3h/eg7_3h.sce new file mode 100755 index 000000000..cd1af4f0d --- /dev/null +++ b/291/CH7/EX7.3h/eg7_3h.sce @@ -0,0 +1,10 @@ +num=10;
+X= [0.123 0.133 0.124 0.126 0.120 0.130 0.125 0.128 0.124 0.126];
+//disp(variance(X))
+s2 = variance(X);
+chi1 = cdfchi("X",num-1,0.95, 0.05 );
+chi2 = cdfchi("X",num-1,0.05, 0.95 );
+//disp(chi1, chi2)
+lowerlim = (num-1)*s2/chi2;
+upperlim = (num-1)*s2/chi1;
+disp(sqrt(upperlim), "to ",sqrt(lowerlim),"The 90% confidence interval is " )
\ No newline at end of file diff --git a/291/CH7/EX7.4a/eg7_4a.sce b/291/CH7/EX7.4a/eg7_4a.sce new file mode 100755 index 000000000..c6a7476f2 --- /dev/null +++ b/291/CH7/EX7.4a/eg7_4a.sce @@ -0,0 +1,19 @@ +A=[36 44 41 53 38 36 34 54 52 37 51 44 35 44];
+B=[52 64 38 68 66 52 60 44 48 46 70 62];
+sigmaA= 40;
+sigmaB= 100;
+alpha = 1-0.95;
+beta= alpha/2;
+meanA = mean(A);
+meanB= mean(B);
+zbeta = cdfnor("X",0, 1, 1-beta, beta );
+
+lowerlim= mean(A) - mean(B) - (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ;
+upperlim= mean(A) - mean(B) + (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ;
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is " )
+
+beta=alpha;
+zbeta = cdfnor("X",0, 1, 1-beta, beta );
+
+upperlim= mean(A) - mean(B) + (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ;
+disp(upperlim, "A value that exceed the difference of the means with 95% confidence is" )
diff --git a/291/CH7/EX7.4b/eg7_4b.sce b/291/CH7/EX7.4b/eg7_4b.sce new file mode 100755 index 000000000..f6eaba5fc --- /dev/null +++ b/291/CH7/EX7.4b/eg7_4b.sce @@ -0,0 +1,25 @@ +tech1 = [140 136 138 150 152 144 132 142 150 154 136 142];
+tech2 = [144 132 136 140 128 150 130 134 130 146 128 131 137 135];
+num1= 12;
+num2= 14;
+mean1= mean(tech1);
+mean2= mean(tech2);
+//disp(mean1)
+//disp(Sp)
+alpha = 0.9;
+S1 = variance(tech1) //*num1/(num1-1);
+S2 = variance(tech2) // *num2/(num2-1);
+Sp = (((num1-1)*S1) + ((num2-1)*S2))/(num1+ num2 -2);
+Sp= sqrt(Sp);
+num= (1/num1)+(1/num2);
+betaa = (1-alpha)/2;
+tval = cdft("T", num1+num2-2, 1-betaa, betaa);
+upperlim = mean1-mean2 + (tval*Sp)*sqrt(num);
+lowerlim = mean1-mean2 - (tval*Sp)*sqrt(num);
+disp(upperlim, "to ",lowerlim,"The 90% confidence interval is " )
+alpha = 0.95
+betaaa = 1-alpha;
+tval = cdft("T", num1+num2-2, 1-betaaa, betaaa);
+lowerlim = mean1-mean2 - (tval*Sp)*sqrt(num);
+disp("the upper confidence interval is")
+disp(" to infinity", lowerlim)
\ No newline at end of file diff --git a/291/CH7/EX7.5a/eg7_5a.sce b/291/CH7/EX7.5a/eg7_5a.sce new file mode 100755 index 000000000..65c4c6224 --- /dev/null +++ b/291/CH7/EX7.5a/eg7_5a.sce @@ -0,0 +1,7 @@ +phat = 0.8;
+zalpha = 1.96;
+
+samplesize = 100;
+lowerlim = phat - (zalpha*sqrt(phat*(1-phat)/samplesize));
+upperlim = phat + (zalpha*sqrt(phat*(1-phat)/samplesize));
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is " )
\ No newline at end of file diff --git a/291/CH7/EX7.5b/eg7_5b.sce b/291/CH7/EX7.5b/eg7_5b.sce new file mode 100755 index 000000000..6e26eb71c --- /dev/null +++ b/291/CH7/EX7.5b/eg7_5b.sce @@ -0,0 +1,7 @@ +phat = 0.52;
+error = 0.04;
+zalpha = 1.96;
+//lowerlim = phat - (zalpha*sqrt(phat*(1-phat)/samplesize));
+//upperlim = phat + (zalpha*sqrt(phat*(1-phat)/samplesize));
+samplesize = (error/zalpha)^2/(phat*(1-phat));
+disp(1/samplesize)
\ No newline at end of file diff --git a/291/CH7/EX7.5c/eg7_5c.sce b/291/CH7/EX7.5c/eg7_5c.sce new file mode 100755 index 000000000..dd3baee47 --- /dev/null +++ b/291/CH7/EX7.5c/eg7_5c.sce @@ -0,0 +1,14 @@ +initialsample = 30;
+acceptable= 26;
+phat = acceptable/initialsample;
+error = 0.05/2;
+zalpha = 2.58;
+
+samplesize = (error/zalpha)^2/(phat*(1-phat));
+finalsize = ceil(1/samplesize);
+acceptablenew= 1040 + acceptable;
+phat = acceptablenew/finalsize;
+lowerlim = phat - (zalpha*sqrt(phat*(1-phat)/finalsize));
+upperlim = phat + (zalpha*sqrt(phat*(1-phat)/finalsize));
+disp(upperlim, "to ",lowerlim,"The 99% confidence interval is " )
+
diff --git a/291/CH7/EX7.6a/eg7_6a.sce b/291/CH7/EX7.6a/eg7_6a.sce new file mode 100755 index 000000000..2fac04a36 --- /dev/null +++ b/291/CH7/EX7.6a/eg7_6a.sce @@ -0,0 +1,11 @@ +sum_lives = 1740;
+num = 10;
+alpha = (1-0.95)/2;
+chi1= cdfchi("X", (2*num), alpha, 1-alpha);
+chi2 = cdfchi("X", (2*num), 1-alpha, alpha);
+//disp(chi2)
+lowerlim = 2*sum_lives/chi2;
+upperlim = 2*sum_lives/chi1;
+disp(upperlim, "to ",lowerlim,"The 95% confidence interval is " )
+
+//The confidence interval is from 101.847 to 360.211 whereas my solution in Scilab is 101.84489 to
362.8485 because of the difference in the value of chi-square(0.975, 20). The textbook says the value is
9.661 whereas scilab calculates its value as 9.59
\ No newline at end of file diff --git a/291/CH7/EX7.7a/eg7_7a.sce b/291/CH7/EX7.7a/eg7_7a.sce new file mode 100755 index 000000000..ffca665a0 --- /dev/null +++ b/291/CH7/EX7.7a/eg7_7a.sce @@ -0,0 +1,10 @@ +function result1= estimator1(X)
+ result1= X(1);
+ //result2= mean(X);
+
+endfunction
+function result2= estimator2(X)
+ //result1= X(1);
+ result2= mean(X);
+
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.7b/eg7_7b.sce b/291/CH7/EX7.7b/eg7_7b.sce new file mode 100755 index 000000000..005b04154 --- /dev/null +++ b/291/CH7/EX7.7b/eg7_7b.sce @@ -0,0 +1,11 @@ +function result1 = estimate(d, sigma)
+ sigmainv = 1/sigma;
+ new = d./sigma;
+ result1 = sum(new)/sum(sigmainv);
+endfunction
+
+function result2 = mserror( sigma)
+ sigmainv = 1/sigma;
+
+ result1 = 1/sum(sigmainv);
+endfunction
diff --git a/291/CH7/EX7.7c/eg7_7c.sce b/291/CH7/EX7.7c/eg7_7c.sce new file mode 100755 index 000000000..d5c35b847 --- /dev/null +++ b/291/CH7/EX7.7c/eg7_7c.sce @@ -0,0 +1,4 @@ +function result = unbiasedestimator(X, n)
+ c=(n+2)/(n+1);
+ result = c*max(X);
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.8a/eg7_8a.sce b/291/CH7/EX7.8a/eg7_8a.sce new file mode 100755 index 000000000..737939d88 --- /dev/null +++ b/291/CH7/EX7.8a/eg7_8a.sce @@ -0,0 +1,3 @@ +function result= estimator(X, n)
+ result= (sum(X) +1)/(n+2);
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.8b/eg7_8b.sce b/291/CH7/EX7.8b/eg7_8b.sce new file mode 100755 index 000000000..3bd50dc71 --- /dev/null +++ b/291/CH7/EX7.8b/eg7_8b.sce @@ -0,0 +1,8 @@ +function result= meanestimator(sigma0 , u, sigma, n, X)
+ meanX= mean(X);
+ result = (n*meanX/sigma0)/((n/sigma0)+(1/sigma)) + (u/sigma)/((n/sigma0)+(1/sigma));
+endfunction
+
+function result= varestimator(sigma0 , sigma, n)
+ result = (sigma0*sigma)/((n*sigma)+sigma0);
+endfunction
\ No newline at end of file diff --git a/291/CH7/EX7.8d/eg7_8d.sce b/291/CH7/EX7.8d/eg7_8d.sce new file mode 100755 index 000000000..2e4570a6b --- /dev/null +++ b/291/CH7/EX7.8d/eg7_8d.sce @@ -0,0 +1,23 @@ +function result= meanestimator(sigma0 , u, sigma, n, X)
+ meanX= mean(X);
+ result = (n*meanX/sigma0)/((n/sigma0)+(1/sigma)) + (u/sigma)/((n/sigma0)+(1/sigma));
+endfunction
+
+function result= varestimator(sigma0 , sigma, n)
+ result = (sigma0*sigma)/((n*sigma)+sigma0);
+endfunction
+
+u = 50;
+sigma= 100;
+sigma0 = 60;
+n =1;
+X =40;
+expec = meanestimator(sigma0 , u, sigma, n, X);
+var = varestimator (sigma0, sigma,n);
+//disp(expec);
+//disp(var);
+
+zalpha = 1.645
+lowerlim = -1*sqrt(var)*zalpha+expec;
+upperlim = sqrt(var)*zalpha+expec;
+disp(upperlim, "to ",lowerlim,"With probability 0.9, the sent signal lies between ", )
\ No newline at end of file diff --git a/291/CH8/EX8.3a/eg8_3a.sce b/291/CH8/EX8.3a/eg8_3a.sce new file mode 100755 index 000000000..2aa38590d --- /dev/null +++ b/291/CH8/EX8.3a/eg8_3a.sce @@ -0,0 +1,12 @@ +noise_var = 4;
+noise_mean= 0;
+num = 5;
+Xbar = 9.5;
+u = 8;
+statistic = sqrt(num/noise_var)*(Xbar - u);
+compare = cdfnor("X", 0, 1, 0.975, 0.025);
+if(statistic<compare)
+ disp("Hypothesis is accepted");
+else
+ disp("Hypothesis is not accepted")
+end
\ No newline at end of file diff --git a/291/CH8/EX8.3b/eg8_3b.sce b/291/CH8/EX8.3b/eg8_3b.sce new file mode 100755 index 000000000..58086b7d0 --- /dev/null +++ b/291/CH8/EX8.3b/eg8_3b.sce @@ -0,0 +1,9 @@ +noise_var = 4;
+noise_mean= 0;
+num = 5;
+Xbar = 8.5;
+u = 8;
+statistic = sqrt(num/noise_var)*(Xbar - u);
+
+prob = 2*cdfnor("PQ", -1*statistic , 0,1 );
+disp(prob, "P-value is")
\ No newline at end of file diff --git a/291/CH8/EX8.3c/eg8_3c.sce b/291/CH8/EX8.3c/eg8_3c.sce new file mode 100755 index 000000000..e49e145f1 --- /dev/null +++ b/291/CH8/EX8.3c/eg8_3c.sce @@ -0,0 +1,10 @@ +noise_var = 4;
+num = 5;
+Xbar = 10;
+u = 8;
+statistic = sqrt(num/noise_var)*(Xbar - u);
+compare = cdfnor("X", 0, 1, 0.975, 0.025);
+lim1 = statistic + compare;
+lim2 = statistic - compare;
+prob = cdfnor("PQ", lim1 , 0,1 ) - cdfnor("PQ", lim2 , 0,1 );
+disp(prob)
\ No newline at end of file diff --git a/291/CH8/EX8.3d/eg8_3d.sce b/291/CH8/EX8.3d/eg8_3d.sce new file mode 100755 index 000000000..017239a79 --- /dev/null +++ b/291/CH8/EX8.3d/eg8_3d.sce @@ -0,0 +1,19 @@ +alpha = 0.025;
+betaa = 0.25;
+
+u1 = 9.2;
+uo = 8;
+var =4;
+zalpha = cdfnor("X", 0, 1, 1-alpha, alpha);
+zbeta = cdfnor("X", 0, 1, 1-betaa, betaa);
+//disp(zalpha);
+n = ((zalpha + zbeta)/(u1-uo))^2 *var;
+disp(ceil(n), "Required number of samples is")
+statistic = sqrt(ceil(n)/var)*(u1 - uo);
+//disp(statistic);
+lim1 = -1*statistic + zalpha;
+lim2 = -1*statistic - zalpha;
+//disp(lim1)
+//disp(lim2)
+prob = cdfnor("PQ", lim1 , 0,1 ) - cdfnor("PQ", lim2 , 0,1 );
+disp(1-prob, "Thus, if the message is sent the reqd number of times is , then the probability that the null hypothesis will be rejected is")
\ No newline at end of file diff --git a/291/CH8/EX8.3e/eg8_3e.sce b/291/CH8/EX8.3e/eg8_3e.sce new file mode 100755 index 000000000..e3712ff9a --- /dev/null +++ b/291/CH8/EX8.3e/eg8_3e.sce @@ -0,0 +1,8 @@ +n =5;
+Xbar = 9.5;
+uo = 8;
+var = 4;
+statistic = sqrt(n/var)*(Xbar - u);
+p = 1 - cdfnor("PQ", statistic, 0, 1);
+disp("The test would call for rejection at all significance levels greater than or equal to ")
+disp(p);
diff --git a/291/CH8/EX8.3f/eg8_3f.sce b/291/CH8/EX8.3f/eg8_3f.sce new file mode 100755 index 000000000..a8db7ca69 --- /dev/null +++ b/291/CH8/EX8.3f/eg8_3f.sce @@ -0,0 +1,8 @@ +n =20;
+Xbar = 1.54;
+uo = 1.6;
+sd = 0.8;
+statistic = sqrt(n)*(Xbar - uo)/sd;
+disp(statistic, "Test statistic is")
+p = cdfnor("PQ", statistic, 0, 1);
+disp(p, "P-value is")
\ No newline at end of file diff --git a/291/CH8/EX8.3g/eg8_3g.sce b/291/CH8/EX8.3g/eg8_3g.sce new file mode 100755 index 000000000..d1b403faa --- /dev/null +++ b/291/CH8/EX8.3g/eg8_3g.sce @@ -0,0 +1,5 @@ +n = 50;
+Xbar = 14.8;
+S = 6.4;
+T = sqrt(n)*Xbar/S;
+disp(T,"The T value is")
\ No newline at end of file diff --git a/291/CH8/EX8.3h/eg8_3h.sce b/291/CH8/EX8.3h/eg8_3h.sce new file mode 100755 index 000000000..b00329678 --- /dev/null +++ b/291/CH8/EX8.3h/eg8_3h.sce @@ -0,0 +1,16 @@ +X= [340 356 332 362 318 344 386 402 322 360 362 354 340 372 338 375 364 355 324 370];
+uo = 350;
+Xbar = mean(X);
+var = variance(X);
+S = sqrt(var)
+//disp(Xbar, sqrt(var));
+n = length(X)
+T = sqrt(n)*(Xbar - uo)/S;
+Tvalue = cdft("T", n-1, 0.95, 0.05 );
+//disp(Tvalue)
+disp(T, "The T value is ")
+if(T<Tvalue)
+ disp("Null hypothesis is accepted at 10% level of significance")
+ else
+ disp("Null hypothesis is not accepted at 10% level of significance")
+end
diff --git a/291/CH8/EX8.3i/eg8_3i.sce b/291/CH8/EX8.3i/eg8_3i.sce new file mode 100755 index 000000000..7a9843103 --- /dev/null +++ b/291/CH8/EX8.3i/eg8_3i.sce @@ -0,0 +1,14 @@ +X= [36.1 40.2 33.8 38.5 42 35.8 37 41 36.8 37.2 33 36];
+n = length(X);
+uo = 40;
+Xbar=mean(X);
+sd = sqrt(variance(X));
+T = sqrt(n)*(Xbar - uo)/sd;
+Tvalue = cdft("T", n-1, 0.05, 0.95 );
+//disp(Tvalue)
+disp(T, "The T value is ")
+if(T<Tvalue)
+ disp("Null hypothesis is rejected at 5% level of significance")
+ else
+ disp("Null hypothesis is accepted at 5% level of significance")
+end
\ No newline at end of file diff --git a/291/CH8/EX8.3j/eg8_3j.sce b/291/CH8/EX8.3j/eg8_3j.sce new file mode 100755 index 000000000..ba982ee85 --- /dev/null +++ b/291/CH8/EX8.3j/eg8_3j.sce @@ -0,0 +1,10 @@ +X = [8.6 9.4 5.0 4.4 3.7 11.4 10.0 7.6 14.4 12.2 11.0 14.4 9.3 10.5 10.3 7.7 8.3 6.4 9.2 5.7 7.9 9.4 9.0 13.3 11.6 10.0 9.5 6.6];
+n = length(X);
+uo = 8;
+Xbar=mean(X);
+sd = sqrt(variance(X));
+T = sqrt(n)*(Xbar - uo)/sd;
+disp(T, "The test statistic is ")
+p = 1- cdft("PQ", T, n-1);
+disp(p, "P-value is")
+disp("A small p value indicates that the mean service time exceeds 8 minutes")
\ No newline at end of file diff --git a/291/CH8/EX8.4a/eg8_4a.sce b/291/CH8/EX8.4a/eg8_4a.sce new file mode 100755 index 000000000..49898c577 --- /dev/null +++ b/291/CH8/EX8.4a/eg8_4a.sce @@ -0,0 +1,12 @@ +A = [61.1 58.2 62.3 64 59.7 66.2 57.8 61.4 62.2 63.6];
+B= [62.2 56.6 66.4 56.2 57.4 58.4 57.6 65.4];
+uA = mean(A);
+uB = mean(B);
+varA = 40^2;
+varB =60^2;
+n= length(A);
+m =length(B);
+den = sqrt((varA/n)+ (varB/m));
+statistic = (uA -uB)/den;
+disp(statistic, "The test statistic is");
+disp("A small value of the test statistic indicates that the null hypothesis is accepted")
\ No newline at end of file diff --git a/291/CH8/EX8.4b/eg8_4b.sce b/291/CH8/EX8.4b/eg8_4b.sce new file mode 100755 index 000000000..605ba7cd4 --- /dev/null +++ b/291/CH8/EX8.4b/eg8_4b.sce @@ -0,0 +1,19 @@ +X = [5.5 6.0 7.0 6.0 7.5 6.0 7.5 5.5 7.0 6.5];
+Y = [6.5 6.0 8.5 7.0 6.5 8.0 7.5 6.5 7.5 6.0 8.5 7.0 ];
+n = length(X);
+m= length(Y);
+Xbar= mean(X);
+Ybar = mean(Y);
+Sx = variance(X);
+Sy = variance(Y);
+Sp = ((n-1)*Sx/(n+m-2)) + ((m-1)*Sy/(n+m-2));
+den = sqrt(Sp*((1/n)+(1/m)));
+TS = (Xbar -Ybar)/den;
+disp(TS, "The test statistic is");
+tvalue = cdft("T", m+n-2, 0.95, 0.05)
+//disp(tvalue)
+if(TS<tvalue)
+ disp("Null hypothesis is rejected at 5% level of significance")
+ else
+ disp("Null hypothesis is accepted at 5% level of significance")
+end
diff --git a/291/CH8/EX8.4c/eg8_4c.sce b/291/CH8/EX8.4c/eg8_4c.sce new file mode 100755 index 000000000..e1a4f79e9 --- /dev/null +++ b/291/CH8/EX8.4c/eg8_4c.sce @@ -0,0 +1,15 @@ +A = [61.1 58.2 62.3 64 59.7 66.2 57.8 61.4 62.2 63.6];
+B= [62.2 56.6 66.4 56.2 57.4 58.4 57.6 65.4];
+uA = mean(A);
+uB = mean(B);
+n= length(A);
+m =length(B);
+Sx = variance(A);
+Sy = variance(B);
+Sp = ((n-1)*Sx/(n+m-2)) + ((m-1)*Sy/(n+m-2));
+den = sqrt(Sp*((1/n)+(1/m)));
+TS = (uA-uB)/den;
+disp(TS, "The test statistic is");
+pvalue = 2*(1- cdft("PQ", TS, m+n-2));
+//disp(tvalue)
+disp(pvalue, "Null hypothesis is accepted at any significance level less than")
diff --git a/291/CH8/EX8.4d/eg8_4d.sce b/291/CH8/EX8.4d/eg8_4d.sce new file mode 100755 index 000000000..e38e55d44 --- /dev/null +++ b/291/CH8/EX8.4d/eg8_4d.sce @@ -0,0 +1,12 @@ +A = [30.5 18.5 24.5 32 16 15 23.5 25.5 28 18];
+B = [23 21 22 28.5 14.5 15.5 24.5 21 23.5 16.5];
+n= length(A);
+W = B-A;
+Wbar = mean(W);
+S = sqrt(variance(W));
+T = sqrt(n)*Wbar/S;
+
+disp(T, "The test statistic is");
+pvalue = cdft("PQ", T, n-1);
+//disp(tvalue)
+disp(pvalue, "The p value is")
diff --git a/291/CH8/EX8.5a/eg8_5a.sce b/291/CH8/EX8.5a/eg8_5a.sce new file mode 100755 index 000000000..bae854c9a --- /dev/null +++ b/291/CH8/EX8.5a/eg8_5a.sce @@ -0,0 +1,7 @@ +n =20;
+S2= 0.025;
+chk = 0.15;
+compare = (n-1)*S2/(chk^2);
+pvalue = 1- cdfchi("PQ", compare, n-1);
+disp(pvalue, "The p-value is")
+disp("Thus , the null hypothesis is accepted")
\ No newline at end of file diff --git a/291/CH8/EX8.5b/eg8_5b.sce b/291/CH8/EX8.5b/eg8_5b.sce new file mode 100755 index 000000000..a440314f8 --- /dev/null +++ b/291/CH8/EX8.5b/eg8_5b.sce @@ -0,0 +1,13 @@ +S1 = 0.14;
+S2 = 0.28;
+n= 10;
+m= 12;
+ratio = S1/S2;
+prob1 = cdff("PQ", ratio, n-1, m-1);
+prob2 = 1-prob1;
+prob = min([prob1 prob2]);
+pvalue = 2*prob;
+disp(pvalue, "The p value is")
+disp("So the hypothesis of equal variance cannot be rejected")
+
+
\ No newline at end of file diff --git a/291/CH8/EX8.6a/eg8_6a.sce b/291/CH8/EX8.6a/eg8_6a.sce new file mode 100755 index 000000000..5ef30e2e9 --- /dev/null +++ b/291/CH8/EX8.6a/eg8_6a.sce @@ -0,0 +1,6 @@ +samplesize = 300;
+p =0.02;
+defective=9;
+val = 1- cdfbin("PQ", defective, samplesize, p, 1-p);
+disp(val, "P0.02{X>10} = ");
+disp("Manufacturers claim cannot be rejected at the 5% level of significance")
diff --git a/291/CH8/EX8.6b/eg8_6b.sce b/291/CH8/EX8.6b/eg8_6b.sce new file mode 100755 index 000000000..ee72cd0f9 --- /dev/null +++ b/291/CH8/EX8.6b/eg8_6b.sce @@ -0,0 +1,9 @@ +samplesize = 300;
+p =0.02;
+defective=9;
+compare = 10;
+npo = samplesize*p;
+sd = sqrt(npo*(1-p));
+tol = 0.5;
+pvalue = 1- cdfnor("PQ", compare-tol, npo,sd );
+disp(pvalue, "The pvalue is")
\ No newline at end of file diff --git a/291/CH8/EX8.6c/eg8_6c.sce b/291/CH8/EX8.6c/eg8_6c.sce new file mode 100755 index 000000000..45d4068d5 --- /dev/null +++ b/291/CH8/EX8.6c/eg8_6c.sce @@ -0,0 +1,7 @@ +samplesize = 500;
+p =0.04;
+defective=16;
+prob1 = cdfbin("PQ", defective, samplesize, p, 1-p)
+prob2 = 1- cdfbin("PQ", defective-1, samplesize, p, 1-p);
+pvalue = 2*min([prob1 prob2]);
+disp(pvalue, "The pvalue is")
diff --git a/291/CH8/EX8.7a/eg8_7a.sce b/291/CH8/EX8.7a/eg8_7a.sce new file mode 100755 index 000000000..a8dfb3642 --- /dev/null +++ b/291/CH8/EX8.7a/eg8_7a.sce @@ -0,0 +1,5 @@ +x = [28 34 32 38 22];
+claim = 25;
+total = sum(x);
+pval = 1 - cdfpoi("PQ", total-1, (claim*length(x)));
+disp(pval, "The pvalue is")
\ No newline at end of file diff --git a/291/CH8/EX8.7b/eg8_7b.sce b/291/CH8/EX8.7b/eg8_7b.sce new file mode 100755 index 000000000..6c6188ed6 --- /dev/null +++ b/291/CH8/EX8.7b/eg8_7b.sce @@ -0,0 +1,12 @@ +plant1 = [16 18 9 22 17 19 24 8];
+plant2 = [22 18 26 30 25 28];
+X1= sum(plant1);
+X2 = sum(plant2);
+n =length(X1);
+m= length(X2);
+//disp(X1, X2, X1+X2)
+prob1 = 1 - cdfbin("PQ",X1 -1,X1+X2, (4/7), (3/7) );
+prob2 = cdfbin("PQ",X1 ,X1+X2, 4/7, 3/7 );
+disp(prob1, prob2)
+pvalue = 2*min([prob1 prob2]);
+disp(pvalue, "The pvalue is")
\ No newline at end of file diff --git a/291/CH8/EX8.7c/eg8_7c.sce b/291/CH8/EX8.7c/eg8_7c.sce new file mode 100755 index 000000000..2846deeea --- /dev/null +++ b/291/CH8/EX8.7c/eg8_7c.sce @@ -0,0 +1,7 @@ +Aerror =28;
+Berror = 18;
+common =10;
+N2 = Aerror - common;
+N3 =Berror- common;
+pval = 1- cdfbin("PQ", N2-1, N2 + N3, 0.5, 0.5);
+disp(pval, "P-value is")
\ No newline at end of file diff --git a/291/CH9/EX9.10a/eg9_10a.sce b/291/CH9/EX9.10a/eg9_10a.sce new file mode 100755 index 000000000..d677b0bc5 --- /dev/null +++ b/291/CH9/EX9.10a/eg9_10a.sce @@ -0,0 +1,37 @@ +x1= [679 1420 1349 296 6975 323 4200 633];
+x2 = [30.4 34.1 17.2 26.8 29.1 18.7 32.6 32.5];
+y = ones(8,1);
+y= [11.6 ;16.1; 9.3; 9.1; 8.4; 7.7; 11.3; 8.4];
+x = ones(8,3);
+for i=1:8
+ x(i,2)= x1(i);
+ x(i,3)= x2(i);
+end
+
+pro1 = x';
+//disp(pro1);
+
+pro2= pro1*x;
+//disp(pro2);
+pro3 = inv(pro2);
+//disp(pro3);
+pro4 = pro3*pro1;
+pro5 = pro4*y;
+//disp(pro4);
+//disp(y);
+B= ones(3,1);
+for i=1:3
+ B(i,1)= 0;
+ for k=1:8
+ B(i,1)=B(i,1)+(pro4(i, k)*y(k, 1));
+ end
+end
+disp(B);
+//SSR = y'*y - B'*x'y;
+SSR = y';
+SSR= SSR*y;
+sub = B';
+sub = sub*x';
+sub= sub*y;
+SSR =SSR - sub;
+disp(SSR, "SSr is");
diff --git a/291/CH9/EX9.10b/eg9_10b.sce b/291/CH9/EX9.10b/eg9_10b.sce new file mode 100755 index 000000000..5e1ac2a4d --- /dev/null +++ b/291/CH9/EX9.10b/eg9_10b.sce @@ -0,0 +1,44 @@ +x1= [679 1420 1349 296 6975 323 4200 633];
+x2 = [30.4 34.1 17.2 26.8 29.1 18.7 32.6 32.5];
+y = ones(8,1);
+n= 8;
+k =2;
+y= [11.6 ;16.1; 9.3; 9.1; 8.4; 7.7; 11.3; 8.4];
+x = ones(8,3);
+for i=1:8
+ x(i,2)= x1(i);
+ x(i,3)= x2(i);
+end
+
+pro1 = x';
+//disp(pro1);
+
+pro2= pro1*x;
+//disp(pro2);
+pro3 = inv(pro2);
+//disp(pro3);
+pro4 = pro3*pro1;
+pro5 = pro4*y;
+//disp(pro4);
+//disp(y);
+B= ones(3,1);
+for i=1:3
+ B(i,1)= 0;
+ for k=1:8
+ B(i,1)=B(i,1)+(pro4(i, k)*y(k, 1));
+ end
+end
+//disp(B);
+//SSR = y'*y - B'*x'y;
+SSR = y';
+SSR= SSR*y;
+sub = B';
+sub = sub*x';
+sub= sub*y;
+SSR =SSR - sub;
+//disp(SSR, "SSr is");
+k=2;
+den = n-k-1;
+disp(den)
+sigma = SSR/den;
+disp(sigma, "The variance is")
\ No newline at end of file diff --git a/291/CH9/EX9.10c/eg9_10c.sce b/291/CH9/EX9.10c/eg9_10c.sce new file mode 100755 index 000000000..c4e637a3b --- /dev/null +++ b/291/CH9/EX9.10c/eg9_10c.sce @@ -0,0 +1,44 @@ +x1 = [44 33 33 32 34 31 33 30 34 34 33 36 33 34 37];
+x2= [1.3 2.2 2.2 2.6 2.0 1.8 2.2 3.6 1.6 1.5 2.2 1.7 2.2 1.3 2.6];
+x3 = [250 115 75 85 100 75 85 75 225 250 255 175 75 85 90];
+x4= [0.63 0.59 0.56 0.55 0.54 0.59 0.56 0.46 0.63 0.60 0.63 0.58 0.55 0.57 0.62 ];
+y = [18.1; 19.6; 16.6; 16.4; 16.9 ;17.0; 20.0; 16.6; 16.2; 18.5 ; 18.7; 19.4; 17.6; 18.3; 18.8];
+n =length(x1);
+x= ones(15, 5);
+for i=1:15
+ x(i,2)= x1(i);
+ x(i,3)= x2(i);
+ x(i,4)= x3(i);
+ x(i,5)= x4(i);
+end
+pro1 = x';
+//disp(pro1);
+pro2= pro1*x;
+//disp(pro2);
+pro3 = inv(pro2);
+//disp(pro3);
+pro4 = pro3*pro1;
+pro5 = pro4*y;
+
+for i=1:5
+ B(i,1)= 0;
+ for k=1:15
+ B(i,1)=B(i,1)+(pro4(i, k)*y(k, 1));
+ end
+end
+SSR = y';
+SSR= SSR*y;
+sub = B';
+sub = sub*x';
+sub= sub*y;
+SSR =SSR - sub;
+//disp(SSR);
+//disp(B(2))
+xxinv = 0.379;
+k= 4;
+ts = sqrt((n-k-2)/SSR)*B(2)/0.616;
+pvalue = 2*(1- cdft("PQ",ts, n-k-2 ));
+disp(pvalue, "The p-value is")
+
+The SSR calculated by scilab is 19.34 whereas the textbook gives the value as 19.26 , thus the
+difference in the final answer.
diff --git a/291/CH9/EX9.10d/eg9_10d.sce b/291/CH9/EX9.10d/eg9_10d.sce new file mode 100755 index 000000000..d8ce66506 --- /dev/null +++ b/291/CH9/EX9.10d/eg9_10d.sce @@ -0,0 +1,53 @@ +y=[79.2 ;64.0; 55.7; 56.3; 58.6; 84.3; 70.4; 61.3; 51.3; 49.8];
+x1 = [0.02 0.03 0.03 0.04 0.10 0.15 0.15 0.09 0.13 0.09];
+x2 = [1.05 1.20 1.25 1.30 1.30 1.00 1.10 1.20 1.40 1.40];
+tvalue= 2.365;
+x = ones(10,3);
+for i=1:10
+ x(i,2)= x1(i);
+ x(i,3)= x2(i);
+end
+
+pro1 = x';
+//disp(pro1);
+
+pro2= pro1*x;
+//disp(pro2);
+pro3 = inv(pro2);
+//disp(pro3);
+pro4 = pro3*pro1;
+pro5 = pro4*y;
+//disp(pro4);
+//disp(y);
+B= ones(3,1);
+for i=1:3
+ B(i,1)= 0;
+ for k=1:10
+ B(i,1)=B(i,1)+(pro4(i, k)*y(k, 1));
+ end
+end
+//disp(B);
+//SSR = y'*y - B'*x'y;
+SSR = y';
+SSR= SSR*y;
+sub = B';
+sub = sub*x';
+sub= sub*y;
+SSR =SSR - sub;
+disp(SSR, "SSr is");
+smallx = [1, 0.15, 1.15];
+product = smallx * B;
+//disp(product);
+n = 10;
+k=2;
+val= sqrt(SSR/(n-k-1));
+//disp(val);
+
+pro5 = smallx * pro3;
+pro6 = pro5* smallx';
+pro7 = val*sqrt(pro6)*tvalue;
+//disp(pro7)
+up = product + pro7;
+low = product - pro7;
+disp(" 95% confidence interval is from ");
+disp(up, "to", low);
\ No newline at end of file diff --git a/291/CH9/EX9.11a/eg9_11a.sce b/291/CH9/EX9.11a/eg9_11a.sce new file mode 100755 index 000000000..30c8ce1a1 --- /dev/null +++ b/291/CH9/EX9.11a/eg9_11a.sce @@ -0,0 +1,5 @@ +cancer = 84;
+total = 111;
+level = 250;
+alpha= -1*log((total-cancer)/total)/level;
+disp(alpha , "Alpha is ")
\ No newline at end of file diff --git a/291/CH9/EX9.1a/9_1a.png b/291/CH9/EX9.1a/9_1a.png Binary files differnew file mode 100755 index 000000000..60a412dcd --- /dev/null +++ b/291/CH9/EX9.1a/9_1a.png diff --git a/291/CH9/EX9.1a/eg9_1a.sce b/291/CH9/EX9.1a/eg9_1a.sce new file mode 100755 index 000000000..098d61eca --- /dev/null +++ b/291/CH9/EX9.1a/eg9_1a.sce @@ -0,0 +1,4 @@ +X= [100 110 120 130 140 150 160 170 180 190];
+Y= [45 52 54 63 62 68 75 76 92 88];
+plot2d(X, Y, -1);
+disp("A linear regression model seems appropriate")
\ No newline at end of file diff --git a/291/CH9/EX9.2a/9_2a.png b/291/CH9/EX9.2a/9_2a.png Binary files differnew file mode 100755 index 000000000..59f2bb8f2 --- /dev/null +++ b/291/CH9/EX9.2a/9_2a.png diff --git a/291/CH9/EX9.2a/eg9_2a.sce b/291/CH9/EX9.2a/eg9_2a.sce new file mode 100755 index 000000000..ff3501fdf --- /dev/null +++ b/291/CH9/EX9.2a/eg9_2a.sce @@ -0,0 +1,9 @@ +A = [46 53 29 61 36 39 47 49 52 38 55 32 57 54 44];
+B = [12 15 7 17 10 11 11 12 14 9 16 8 18 14 12];
+plot2d(A, B, -1);
+[X, Y] = reglin(A, B);
+//disp(X);
+//disp(Y);
+p = 0 : 0.1: 65;
+q = p.*X + Y
+plot2d(p, q, 2);
\ No newline at end of file diff --git a/291/CH9/EX9.3a/9_3a.png b/291/CH9/EX9.3a/9_3a.png Binary files differnew file mode 100755 index 000000000..fa3325fa4 --- /dev/null +++ b/291/CH9/EX9.3a/9_3a.png diff --git a/291/CH9/EX9.3a/eg9_3a.sce b/291/CH9/EX9.3a/eg9_3a.sce new file mode 100755 index 000000000..a54eb1dcc --- /dev/null +++ b/291/CH9/EX9.3a/eg9_3a.sce @@ -0,0 +1,30 @@ +x= [5 6 7 10 12 15 18 20];
+y= [7.4 9.3 10.6 15.4 18.1 22.2 24.1 24.8];
+plot2d(x,y,-1);
+
+xbar = mean(x);
+ybar= mean(y);
+n= 8;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+disp(A, "A is");
+disp(B, "B is");
+p= 0:0.1: 20;
+q= A + B*p;
+plot2d(p,q,2);
+
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+disp(SSR, "The SSR is")
\ No newline at end of file diff --git a/291/CH9/EX9.4a/eg9_4a.sce b/291/CH9/EX9.4a/eg9_4a.sce new file mode 100755 index 000000000..93a0883ea --- /dev/null +++ b/291/CH9/EX9.4a/eg9_4a.sce @@ -0,0 +1,34 @@ +x= [45 50 55 60 65 70 75];
+y= [24.2 25.0 23.3 22.0 21.5 20.6 19.8];
+xbar = mean(x);
+ybar= mean(y);
+n= 7;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+//disp(A, "A is");
+//disp(B, "B is");
+
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+//disp(SSR, "The SSR is")
+ts = sqrt(((n-2)*Sxx)/SSR)*abs(B);
+disp(ts, "the test statistic is");
+tvalue= cdft("T",5, 0.995, 0.005 );
+//disp(tvalue, "tvalue is");
+if(tvalue < ts)
+ disp("Hypothesis beta= 0 is rejected at 1% level of significance")
+else
+ disp("Hypothesis beta= 0 is accepted at 1% level of significance")
+ end
\ No newline at end of file diff --git a/291/CH9/EX9.4b/eg9_4b.sce b/291/CH9/EX9.4b/eg9_4b.sce new file mode 100755 index 000000000..33b2c94e0 --- /dev/null +++ b/291/CH9/EX9.4b/eg9_4b.sce @@ -0,0 +1,31 @@ +x= [45 50 55 60 65 70 75];
+y= [24.2 25.0 23.3 22.0 21.5 20.6 19.8];
+xbar = mean(x);
+ybar= mean(y);
+n= 7;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+//disp(A, "A is");
+//disp(B, "B is");
+
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+//disp(SSR, "The SSR is")
+
+tvalue= cdft("T",5, 0.975, 0.025 );
+k = sqrt(SSR/((n-2)*Sxx))*tvalue;
+int1 = B + k;
+int2= B-k;
+disp(int2, "to ", int1 ,"The 95% confidence interval is " );
\ No newline at end of file diff --git a/291/CH9/EX9.4c/9_4c.png b/291/CH9/EX9.4c/9_4c.png Binary files differnew file mode 100755 index 000000000..c2e4bb186 --- /dev/null +++ b/291/CH9/EX9.4c/9_4c.png diff --git a/291/CH9/EX9.4c/eg9_4c.sce b/291/CH9/EX9.4c/eg9_4c.sce new file mode 100755 index 000000000..b5488eca1 --- /dev/null +++ b/291/CH9/EX9.4c/eg9_4c.sce @@ -0,0 +1,36 @@ +x= [60 62 64 65 66 67 68 70 72 74];
+y= [63.6 65.2 66 65.5 66.9 67.1 67.4 68.3 70.1 70];
+plot2d(x,y,-1);
+xbar = mean(x);
+ybar= mean(y);
+n= 10;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+//disp(A, "A is");
+//disp(B, "B is");
+p= 60:0.1: 72;
+q= A + B*p;
+plot2d(p,q,2);
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+ts = sqrt(((n-2)*Sxx)/SSR)*(B-1)
+//disp(ts);
+tvalue= cdft("T",n-2, 0.99, 0.01 );
+//disp(tvalue);
+if(ts<(-1*tvalue))
+ disp("Null hypotheis is rejected at 1% level of significance")
+else
+ disp("Null hypotheis is accepted at 1% level of significance")
+end
\ No newline at end of file diff --git a/291/CH9/EX9.4d/eg9_4d.sce b/291/CH9/EX9.4d/eg9_4d.sce new file mode 100755 index 000000000..6ca120bd6 --- /dev/null +++ b/291/CH9/EX9.4d/eg9_4d.sce @@ -0,0 +1,27 @@ +x= [121 96 85 113 102 118 90 84 107 112 95 101];
+y= [104 91 101 110 117 108 96 102 114 96 88 106];
+
+plot2d(x,y,-1);
+xlabel("Deaths in 1988");
+ylabel("Deaths in 1989");
+
+xbar = mean(x);
+ybar= mean(y);
+n= 12;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+disp(A, "A is");
+disp(B, "B is");
diff --git a/291/CH9/EX9.4e/eg9_4e.sce b/291/CH9/EX9.4e/eg9_4e.sce new file mode 100755 index 000000000..ac9a9f6c4 --- /dev/null +++ b/291/CH9/EX9.4e/eg9_4e.sce @@ -0,0 +1,32 @@ +x= [60 62 64 65 66 67 68 70 72 74];
+y= [63.6 65.2 66 65.5 66.9 67.1 67.4 68.3 70.1 70];
+x0 = 68;
+xbar = mean(x);
+ybar= mean(y);
+n= 10;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+//disp(SxY, "SxY is");
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+//disp(Sxx, "Sxx is");
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+//disp(SYY, "SYY is");
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+tvalue= cdft("T",n-2, 0.975, 0.025 );
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+//disp(tvalue, "tvalue is");
+intvl = A + (B*x0);
+//disp(intvl);
+change = sqrt((1/n)+(((x0-xbar)^2)/Sxx))* sqrt(SSR/(n-2))*tvalue;
+intvl1 = intvl - change;
+intvl2= intvl + change;
+disp(intvl2, "to ", intvl1 ,"The 95% confidence interval is " );
\ No newline at end of file diff --git a/291/CH9/EX9.4f/eg9_4f.sce b/291/CH9/EX9.4f/eg9_4f.sce new file mode 100755 index 000000000..4c46c8a0c --- /dev/null +++ b/291/CH9/EX9.4f/eg9_4f.sce @@ -0,0 +1,32 @@ +x= [60 62 64 65 66 67 68 70 72 74];
+y= [63.6 65.2 66 65.5 66.9 67.1 67.4 68.3 70.1 70];
+x0 = 68;
+xbar = mean(x);
+ybar= mean(y);
+n= 10;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+//disp(SxY, "SxY is");
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+//disp(Sxx, "Sxx is");
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+//disp(SYY, "SYY is");
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+tvalue= cdft("T",n-2, 0.975, 0.025 );
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+//disp(tvalue, "tvalue is");
+intvl = A + (B*x0);
+//disp(intvl);
+change = sqrt(((n+1)/n)+(((x0-xbar)^2)/Sxx))* sqrt(SSR/(n-2))*tvalue;
+intvl1 = intvl - change;
+intvl2= intvl + change;
+disp(intvl2, "to ", intvl1 ,"The 95% confidence interval is " );
\ No newline at end of file diff --git a/291/CH9/EX9.5a/eg9_5a.sce b/291/CH9/EX9.5a/eg9_5a.sce new file mode 100755 index 000000000..e5d3e2ffb --- /dev/null +++ b/291/CH9/EX9.5a/eg9_5a.sce @@ -0,0 +1,25 @@ +x= [60 62 64 65 66 67 68 70 72 74];
+y= [63.6 65.2 66 65.5 66.9 67.1 67.4 68.3 70.1 70];
+
+xbar = mean(x);
+ybar= mean(y);
+n= 10;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+R2 = 1 - (SSR/SYY);
+disp(R2, "The coefficient of determination is")
\ No newline at end of file diff --git a/291/CH9/EX9.7a/9_7aa.png b/291/CH9/EX9.7a/9_7aa.png Binary files differnew file mode 100755 index 000000000..72b1bb7af --- /dev/null +++ b/291/CH9/EX9.7a/9_7aa.png diff --git a/291/CH9/EX9.7a/9_7ab.png b/291/CH9/EX9.7a/9_7ab.png Binary files differnew file mode 100755 index 000000000..33fc2e1cf --- /dev/null +++ b/291/CH9/EX9.7a/9_7ab.png diff --git a/291/CH9/EX9.7a/eg9_7a.sce b/291/CH9/EX9.7a/eg9_7a.sce new file mode 100755 index 000000000..3478c3e63 --- /dev/null +++ b/291/CH9/EX9.7a/eg9_7a.sce @@ -0,0 +1,33 @@ +x= [5 10 20 30 40 50 60 80];
+yold= [0.061 0.113 0.192 0.259 0.339 0.401 0.461 0.551];
+plot2d(x, yold, -1);
+y = -1*log(1-yold);
+scf(2);
+plot2d(x, y, -1);
+
+
+xbar = mean(x);
+ybar= mean(y);
+n= 8;
+SxY = 0;
+for i= 1:n
+ SxY = SxY + (x(i)*y(i)) - (xbar*ybar);
+end
+
+Sxx = 0;
+for i=1:n
+ Sxx= Sxx + (x(i)*x(i)) - (xbar*xbar);
+end
+SYY = 0;
+for i=1:n
+ SYY = SYY + (y(i)*y(i)) - (ybar*ybar);
+end
+B = SxY/Sxx;
+A = ybar - (B*xbar);
+//disp(A, "A is");
+//disp(B, "B is");
+SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ;
+chat = exp(-1*A);
+dhat = 1 - exp(-1*B);
+disp(chat, "chat is");
+disp(dhat, "dhat is");
diff --git a/291/CH9/EX9.8b/eg9_8b.sce b/291/CH9/EX9.8b/eg9_8b.sce new file mode 100755 index 000000000..e18564e37 --- /dev/null +++ b/291/CH9/EX9.8b/eg9_8b.sce @@ -0,0 +1,26 @@ +x = [0.5 1 1.5 2 3 4 5 6 8 10];
+y= [15 15.1 16.5 19.9 27.7 29.7 26.7 35.9 42 49.4];
+for i=1:10
+ w(i) = 1/x(i);
+end
+//disp(w)
+n = 10;
+p = zeros(2,2);
+q = zeros(2, 1);
+p(1, 1) = sum(w);
+p(1,2) = n;
+p(2,1) = n;
+p(2,2) = sum(x);
+for i=1:10
+ new(i) = w(i)*y(i)
+end
+
+q(1,1)= -1*sum(new);
+q(2,1) = -1*sum(y);
+//disp(p);
+//disp(q);
+sol = linsolve(p,q);
+A = sol(1,1 );
+B = sol(2,1);
+disp(A, "A is");
+disp(B, "B is");
\ No newline at end of file diff --git a/291/CH9/EX9.9a/9_9a.png b/291/CH9/EX9.9a/9_9a.png Binary files differnew file mode 100755 index 000000000..6506ea329 --- /dev/null +++ b/291/CH9/EX9.9a/9_9a.png diff --git a/291/CH9/EX9.9a/eg9_9a.sce b/291/CH9/EX9.9a/eg9_9a.sce new file mode 100755 index 000000000..b5817129a --- /dev/null +++ b/291/CH9/EX9.9a/eg9_9a.sce @@ -0,0 +1,29 @@ +x = 1:1:10;
+y= [20.6 30.8 55 71.4 97.3 131.8 156.3 197.3 238.7 291.7];
+plot2d(x, y, -1);
+xlabel('X');
+ylabel('Y');
+n = length(x)
+xsquared = x.^2;
+xcube = x.^3;
+xfour = x.^4;
+xy = x.*y;
+x2y = xy.*x;
+p= zeros(3,3);
+q = zeros(3,1);
+p(1,1) = n;
+p(1,2) = sum(x);
+p(1,3)=sum(xsquared);
+p(2,1) = sum(x);
+p(2,2) = sum(xsquared);
+p(2,3)=sum(xcube);
+p(3,1) = sum(xsquared);
+p(3,2) = sum(xcube);
+p(3,3)=sum(xfour);
+q(1,1)= -1*sum(y);
+q(2,1) = -1*sum(xy);
+q(3,1) = -1*sum(x2y);
+B= linsolve(p, q);
+disp(B(1,1), "B0 is");
+disp(B(2,1), "B1 is");
+disp(B(3,1), "B2 is");
\ No newline at end of file |