diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /2360/CH2/EX2.5/ex2_5.sce | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '2360/CH2/EX2.5/ex2_5.sce')
-rwxr-xr-x | 2360/CH2/EX2.5/ex2_5.sce | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/2360/CH2/EX2.5/ex2_5.sce b/2360/CH2/EX2.5/ex2_5.sce new file mode 100755 index 000000000..d293d59aa --- /dev/null +++ b/2360/CH2/EX2.5/ex2_5.sce @@ -0,0 +1,24 @@ +// Exa 2.5
+format('v',7);clc;clear;close;
+// Given data
+// Reported values for average petrol consumption
+x= [25.5 30.3 31.1 29.6 32.4 39.4 28.9 30.0 33.3 31.4 29.5 30.5 31.7 33.0 29.2];
+n = 15;// number of reading
+sigma_x=0;// initialization of variable
+for i=1:1:15
+ sigma_x= sigma_x+x(i);// sum of reading
+end
+Mean =sigma_x/n;// mean value
+disp(Mean,"The mean value is");
+sorted_x= gsort(x);
+Xmedian = sorted_x((n+1)/2);// median value
+disp(Xmedian,"The median value is");
+sigma_d_sq=0;
+for i=1:1:15
+ d(i)=x(i)-Mean
+ sigma_d_sq= sigma_d_sq+d(i)*d(i);
+end
+sigma = round(sqrt( sigma_d_sq/(n-1) ));// standard deviation
+disp(sigma,"The standard deviation is");
+V = sigma^2;// variance
+disp(V,"The variance is");
|