summaryrefslogtreecommitdiff
path: root/331/CH3/EX3.8/Example_3_8.sce
blob: c6196e5a11c53f691da69101c1f100f804bdcd43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//Caption: Median of grouped data
//Example3.8
//Page45
clear;
clc;
X = [0,8;8,10;10,12;12,14;14,16;16,18;18,20;20,22;22,24];
f = [5,10,15,20,35,40,45,20,15,11];
cum_f = 0;
for i = 1:length(f)
    cum_f = cum_f+f(i);
    sigmaf(i) = cum_f;
end
N = cum_f; //total number of salesman
cen = N/2;
for  i = 1:length(f)
    if ((sigmaf(i)< cen) &(cen< sigmaf(i+1))) then
        L = X(i+1,1);
        Fre = f(i+1);
        F = sigmaf(i)
        C = diff(X(i+1,:));
    end
end
disp(L,'Lower limit of the median class L =')
disp(Fre,'Frequency of the Median class f =')
disp(F,'Cumulative frequency of the previous class F=')
disp(C,'Width of the class interval C=')
Median = L+(((N/2)-F)*C/Fre);
disp(Median*1000,'Median of the travelling allowance of the salesman is Rs =')
//Result
// 
// Lower limit of the median class L =   
// 
//    16.  
// 
// Frequency of the Median class f =   
// 
//    40.  
// 
// Cumulative frequency of the previous class F=   
// 
//    85.  
// 
// Width of the class interval C=   
// 
//    2.  
// 
// Median of the travelling allowance of the salesman is Rs =   
// 
//    17150.