You are on page 1of 1

//Stanfard deviation without a distribution

//S.D. = sqrt((1/n)* summation((x(i) - barx)^2 ))


//barx = x(i) - mean
//n = length(x)

function [sd] = stddev(x)


//meanx is mean of sequence x
m = mean(x)
sumbarxsq = 0
n = length(x)

for i=1:length(x)
barx(i) = x(i)-m
end

for i=1:length(x)
barxsq(i) = barx(i)^2
end

for i=1:length(x)
sumbarxsq = sumbarxsq + barxsq(i)
end

onebyn = 1/n

sd = sqrt(onebyn*sumbarxsq)

endfunction

You might also like