summaryrefslogtreecommitdiff
path: root/291/CH2
diff options
context:
space:
mode:
Diffstat (limited to '291/CH2')
-rwxr-xr-x291/CH2/EX2.2a/eg2_2a.sce6
-rwxr-xr-x291/CH2/EX2.2b/2_2bgraph.pngbin0 -> 11332 bytes
-rwxr-xr-x291/CH2/EX2.2b/eg2_2b.sce8
-rwxr-xr-x291/CH2/EX2.3a/eg2_3a.sce4
-rwxr-xr-x291/CH2/EX2.3b/eg2_3b.sce7
-rwxr-xr-x291/CH2/EX2.3c/eg2_3c.sce13
-rwxr-xr-x291/CH2/EX2.3d/eg2_3d.sce7
-rwxr-xr-x291/CH2/EX2.3e/eg2_3e.sce21
-rwxr-xr-x291/CH2/EX2.3f/eg2_3f.sce4
-rwxr-xr-x291/CH2/EX2.3g/eg2_3g.sce3
-rwxr-xr-x291/CH2/EX2.3h/eg2_3h.sce5
-rwxr-xr-x291/CH2/EX2.3i/eg2_3i.sce2
-rwxr-xr-x291/CH2/EX2.4a/eg2_4a.sce5
-rwxr-xr-x291/CH2/EX2.5a/eg2_5a.sce8
-rwxr-xr-x291/CH2/EX2.6a/eg2_6a.sce14
-rwxr-xr-x291/CH2/EX2.6b/eg2_6b.sce14
16 files changed, 121 insertions, 0 deletions
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
new file mode 100755
index 000000000..f3e2adab1
--- /dev/null
+++ b/291/CH2/EX2.2b/2_2bgraph.png
Binary files differ
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