BENG 449 Problem 3 1

BENG 449 Problem 3 1 - Print the results disp disp'Using...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
2/14/08 5:35 PM MATLAB Command Window 1 of 1 >> % BENG 449 -- Problem Set 3, Question 1 % Written by Alex Lemon Question_3_1_Data = [16.4721 8.3191 18.5716 23.1178 11.5411 . .. 19.2900 21.2700 7.0314 7.7952 17.8557]; % Calculate the sample mean % 1.) Using the formula sum_q31_data = 0; len_q31_data = length(Question_3_1_Data); for i = 1:len_q31_data sum_q31_data = sum_q31_data + Question_3_1_Data(i); end mu_formula = sum_q31_data / len_q31_data; % 2.) Using the built-in function mu_builtin = mean( Question_3_1_Data ); % Calculate the sample standard deviation % 1.) Using the formula ssq_q31_data = 0; for i = 1:len_q31_data ssq_q31_data = ssq_q31_data + (Question_3_1_Data(i) - mu_formula)^2; end var_formula = ssq_q31_data / (len_q31_data - 1); % 2.) Using the built-in function var_builtin = var( Question_3_1_Data );
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Print the results: disp([' ']); disp(['Using the formal definition, the sample mean of the data is ', . .. num2str(mu_formula), '.']); disp(['Using the built-in function, the sample mean of the data is ', . .. num2str(mu_builtin), '.']); disp(['Using the formal definition, the sample variance of the data is ', . .. num2str(var_formula), '.']); disp(['Using the built-in function, the sample variance of the data is ', . .. num2str(var_builtin), '.']); Using the formal definition, the sample mean of the data is 15.1264. Using the built-in function, the sample mean of the data is 15.1264. Using the formal definition, the sample variance of the data is 35.3934. Using the built-in function, the sample variance of the data is 35.3934. >>...
View Full Document

This note was uploaded on 07/19/2008 for the course BENG 449 taught by Professor Richardcarson during the Spring '08 term at Yale.

Ask a homework question - tutors are online