From 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 10 Oct 2017 12:27:19 +0530 Subject: initial commit / add all books --- 1415/CH1/EX1.4.2/ex2.jpg | Bin 0 -> 25999 bytes 1415/CH1/EX1.4.2/ex2.sci | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 1415/CH1/EX1.4.2/ex2.jpg create mode 100644 1415/CH1/EX1.4.2/ex2.sci (limited to '1415/CH1/EX1.4.2') diff --git a/1415/CH1/EX1.4.2/ex2.jpg b/1415/CH1/EX1.4.2/ex2.jpg new file mode 100644 index 000000000..5542e2e1c Binary files /dev/null and b/1415/CH1/EX1.4.2/ex2.jpg differ diff --git a/1415/CH1/EX1.4.2/ex2.sci b/1415/CH1/EX1.4.2/ex2.sci new file mode 100644 index 000000000..2de9e56e5 --- /dev/null +++ b/1415/CH1/EX1.4.2/ex2.sci @@ -0,0 +1,28 @@ +//Example 2 Page 98 +clc +clear + +x=[0 2 4 6 8 10 12 14]//assigning x values as given +disp(x,'Years:')//displaying the x values +y=[9 9 10 11 11 12 13 13]//assigning the y values +disp(y,'Per capital GDP:')//displaying y values +xy=x.*y//calculating xy values +disp(xy,'xy:')//displaying xy values +x2=x^2//calculating x^2 values +disp(x2,'square of x')//displaying x^2 values +n=8;//given n=8 data points +disp(sum(x),'sumof x:')//finding the sum of x +disp(sum(y),'sumof y:')//finding the sum of y +disp(sum(xy),'sumof xy:')//finding the sum of xy +disp(sum(x2),'sumof xsquare:')//finding the sum of x2 +m=((n*(sum(xy)))-((sum(x))*(sum(y))))/((n*(sum(x2)))-(sum(x)^2));//calculating m value +disp(m,'m value is:')//displaying m values +b=(sum(y)-(m*sum(x)))/n//calculating b value +disp(b,'b value is:')//displaying b value + +function y=f(x)//function for regression line + y=m*x+b +endfunction +y=f(x)//calling function +plot(x,y)//plotting graph between x and y +xtitle('data point and regression line','x','y')//naming the axex -- cgit