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
Compute the Mean and Standard Deviation for grouped data from given frequencies and class marks passed as parameter lists. Design and write two MATLAB m-file functions that compute these two statistical measures. These two functions should accept as input parameters, two lists observed from the sample: A list of grouped data class marks x_cm, and a list of frequencies f_obs. Use grouped data formulas, e.g. for the Grouped-Mean use sigma(xf)/sigma(f). Inside of these functions use the sum () function and array operations, careful, in the SD function sigma (x^2f) rightarrow sum (x.^2. *f) but (sigma (xf))^2 rightarrow sum (x. *f)^2 Observe the placement of the square operation and the use of^instead of^Print the results with a fprintf () statement inside each of these functions.

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

 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 Compute the Mea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site