diff options
Diffstat (limited to '291/CH9/EX9.5a/eg9_5a.sce')
-rwxr-xr-x | 291/CH9/EX9.5a/eg9_5a.sce | 25 |
1 files changed, 25 insertions, 0 deletions
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 |