diff options
author | Prashant S | 2019-10-04 12:27:32 +0530 |
---|---|---|
committer | GitHub | 2019-10-04 12:27:32 +0530 |
commit | ac2986488a9731cff5cbb517d8f0ef98e2561d64 (patch) | |
tree | 7bb3f64824627ef179d5f341266a664fd0b69011 /Numerical_Methods_by_E_Balaguruswamy/CH10 | |
parent | cbb2770fb2f88246175add29623103a56ba338b8 (diff) | |
parent | b3f3a8ecd454359a2e992161844f2fb599f8238a (diff) | |
download | R_TBC_Uploads-master.tar.gz R_TBC_Uploads-master.tar.bz2 R_TBC_Uploads-master.zip |
Added R TBC
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH10')
-rw-r--r-- | Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..1dfe5184 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,30 @@ +# Example 1 Chapter 10 Page no.: 326
+# Straight Line fitting
+
+x<-c(1,2,3,4,5) # Define table
+y<-c(3,4,5,6,8)
+#Square of X values
+x2<-x^2
+#Product of X and Y
+xy<-x*y
+#Sum of X
+sx<-sum(x)
+#Sum of y
+sy<-sum(y)
+#Sum of x^2
+sx2<-sum(x2)
+#Sum of x*y
+sxy<-sum(xy)
+# number of elements
+n =5
+# calculating slope
+b <- ((n*sxy) -(sx*sy))/((n*sx2)-(sx^2))
+# calculating intercept
+a <- (sy)/n - (b*(sx))/n
+
+cat("The Linear equation y=",a,"+",b,"x")
+
+#Plotting curve and fitting the Straight line
+plot(x,y)
+
+abline(a=a,b=b)
|