我有一个矢量图a
a = [86 100 41 93 75 61 76 92 88 97]
我想自己计算std
and mean
:
>> mean(a)
ans =
80.9000
>> std(a)^2
ans =
335.2111
但是当我这样做时,我得到了错误的方差:
>> avg = mean(a)
avg =
80.9000
>> var = sum(a.^2)/length(a) - avg^2
var =
301.6900
我在这里想念什么?
为什么sum(a.^2)/length(a) - avg^2 != std(a)^2
?