So I noticed a discrepancy while computing a vol, i.e. standard deviation. I manually computed it as follows:
v <- c(9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4)
sqrt(sum((v - mean(v))^ 2) / length(v))
[1] 2.983287
Now if I try sd():
sd(v)
[1] 3.060788
It seems that what sd()
is doing is:
sqrt(sum((v - mean(v))^ 2) / (length(v)-1))
[1] 3.060788
Why is it doing N - 1 for the denominator? The definition of stddev
as I have always learned it specifies to use N as the denominator. What am I missing?