Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a .m file that accepts a vector of data, and calculates the sample mean

ID: 3594765 • Letter: 1

Question

1) Write a .m file that accepts a vector of data, and calculates the sample mean and sample standard deviation.

2) Write a .m file that accepts a vector of data, and calculates a 95% CI of the mean of the data.

3) The data on the amount of whats produced at a small hydroplant are recorded

a)A local community is concerned that not enough power is being produced from the plant. If the town requires 18 Megawatts to maintain its power supply, perform a hypothesis to determine the test statistic

for .Write a concluding statement regarding whether or not there is evidence to reject the hypothesis that the powerplant produces enough power.

b) compute a 95% confidence interval (either by hand or using your .m) of the average megawatts produced by the dam. State whether your confidence interval verifies the result of the hypothesis test from Q3a) . Give reasoning as to how you came up with this statement.

Notes:
1i) you should have 1 vector as a input and two values as outputs (the mean and variance).

1ii)you cannot use MATLABs inbuild sum, mean or var functions, however you should use these to check your answers.

2i) your code should have 1 vector as an input, and 2 values as an output (a lower and upper bound). 2ii) you can use the mean and var functions of MATLAB.
3) use the data file to test your previous code!

15.09555297 15.51812954 20.35519486 19.12858356 14.15049283 17.52099982 20.4099342 19.80132709 17.54272477 21.09709789 19.04856749 23.14979933 15.37804123 22.96336893 20.61179882 19.04849561 16.30280219 16.33769497 19.21356604 18.49197148 20.97641529 21.10913717 18.81666032 19.28838446 21.9522541 19.63512116 21.19992354 17 . 88522722 19.67189166 19.72348015 19.30576983 18.52631747 20.27238793 19.55932928 18.39828845 16.47031883 15.39767167 19.41382284 18.75270783 18.95612691 19.79856301 17.06021975 20.48808268 20.60922298 18.98751708 19.5164253 22.86104295 19.34550242 21.39200357 22.61511719 14.39078827 16.5772142 18.25394438 18.0351486 18.27010607 20.95712398 16.17147392 18.02301707 18.63377286 19.68507444 16.98037395 17.66993713 21.95970048 22.24072255 18.30471333 20.97799504 17.27308578 20.29939255 19.83302609 22.12661148 20.47836944 19.9744501 15.45795761 20.5848656 19.33634638 20.96467577 17.06454064 18.28773515 14.89954483 20.45850828 20.47252923 19.9160093 17.08445419 18.06390195 18.30035411 15.65294538 19.74432775 16.64180369 21.67837332 19.64851438 19.5355638 18.53788005 20.02638358 21.29996782 18.38797563 13.61275656 14.43708441 18.75088357 20.44338199 19.58974372 17.77888638 17.58802534 21.64670095 20.67532743 19.80343037 16.4364451 21.25123505 20.8062855

Explanation / Answer

%function to find mean and standard deviation:

function [mean,sdev]=MeanSdev(data)
n=numel(data);
s=0;
for i =1:n
s=s+data(i);
end
mean=s/n;
sqDiff=0;%squared difference sum
for i =1:n
a=(mean-data(i))^2;
sqDiff=sqDiff+a;
end
var=sqDiff/n;%variance
sdev=sqrt(var);

%function to find 95% confidence interval

function [upperL,lowerL]=CI95(data)
n=numel(data);
Mean=mean(data);
S=std(data);
Z=1.960;%for 95%
upperL=Mean+Z*(S/sqrt(n));
lowerL=Mean-Z*(S/sqrt(n));