diff options
Diffstat (limited to '291/CH2/EX2.3e')
-rwxr-xr-x | 291/CH2/EX2.3e/eg2_3e.sce | 21 |
1 files changed, 21 insertions, 0 deletions
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 |