Age at death (in days) of 78 cases of sudden infant death syndrome (SIDS) in Kin
ID: 2267507 • Letter: A
Question
Age at death (in days) of 78 cases of sudden infant death syndrome (SIDS) in King County, Washington during 1976-1977 is provided below 225 68 176 68 143 47 42 174 64 120 139 57 34 77 274 234 77 307 53 206 65 164 24 79 185 90 104 45 130 187 108 150 76 90 32 96 117 117 88 99 157 44 102 42 96 108 29 80 80 38 80 60 110 171 81 28 87 108 113 23 148 53 85 95 67 92 130 120 61 25 22 115 48 66 65 80 118 87 Write your own MATLAB function to calculate the population and the sample standard deviation, respectively. Use these functions to compute the population and the sample standard deviation of the data. Compare with the output from std0Explanation / Answer
Matlab Script:
function [p s] = stdex(v)
%p is population
%s is standard deviation
p = length(v);%total population
avg = sum(v)/p;%average
sum1 = 0;
for i=1:p
sum1 = sum1+((v(i)-avg)^2);%calculating sum
end
s = sqrt(sum1/(p-1));%finding standard deviation
end
command window log:
v =[225 68 176 68 143 47 42 174 64 120 139 57 34 77 274 234 77 307 53 206 65 164 24 79 185 90 104 45 130 187 108 150 76 90 32 96 117 117 88 99 157 44 102 42 96 108 29 80 80 38 80 60 110 171 81 28 87 108 113 23 148 53 85 95 67 92 130 120 61 25 22 115 48 66 65 80 118 87]
With user defined function
both results are same