data class marks 10 15 20 25 30 35 40 45 observed frequencie
| data class marks | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 |
| observed frequencies | 10 | 13 | 65 | 87 | 90 | 23 | 20 | 8 |
| expected frequencies | 6.5 | 22.8 | 54.6 | 82.7 | 78.9 | 47.3 | 17.8 | 5.4 |
Solution
%Create first file named mymean.m, and paste below code in it (please give file names as I said, otherwise it wont work)
function m = mymean(x_cm,f_obs)
m = sum(x_cm*f_obs\')/sum(f_obs);
end
% create second file named SD.m and paste below code in it
function sd = SD(x_cm,f_obs)
m = mymean(x_cm,f_obs);
sd = sqrt(sum(((x_cm - m).^2)*f_obs\')/sum(f_obs));
end
%create one more file drive.m, where we call above functions.
marks = [10,15,20,25,30,35,40,45];
freq = [10,13,65,87,90,23,20,8];
final_mean = mymean(marks,freq);
final_SD = SD(marks,freq);
fprintf(\'%s%f\ \',\'Mean is \', final_mean);
fprintf(\'%s%f\ \', \'Standard Deviation is \',final_SD);
%SAMPLE OUTPUT
%Mean is 26.693038
%Standard Deviation is 7.230216
