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!
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));
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.