11 個のキーワードで学ぶ統計学入門 3 / 母分散

  • Calculator の場合:

構文: varPop(リスト)
実行結果:
f:id:ti-nspire:20180508141958p:plain:w300
(varSamp() は不偏標本分散)
 

  • Nspired Lua で実行する場合:
seq2 = {1,2,3,4,5,6,7,8,9,10}

function varPop(list)
   local temp = "{"..table.concat(list, ",").."}"
   --return math.eval("varPop("..temp..")")
   return math.eval(string.format("varPop(%s)", temp))
end
function on.resize()
   print(varPop(seq2))
end

実行結果:
f:id:ti-nspire:20180508142425p:plain
 

  • Lua だけで組む場合:
function sum(list)
   local temp = 0
   for i = 1, #list do
      temp = temp + list[i]
   end
   return temp
end
function varPop(list)
   local num  = #list
   local mean = sum(list) / num
   local sum2 = 0
   for i = 1, num do
      sum2 = sum2 + (list[i] - mean)^2
   end
   
   return sum2 / num
end

seq2 = {1,2,3,4,5,6,7,8,9,10}
print(varPop(seq2))

実行結果:
f:id:ti-nspire:20180508143230p:plain
―――――――――――――――――――――――――――――――――
Wolfram の場合 (組込函数有無不明のため自作):

s1={1,2,3,4,5,6,7,8,9,10};
N[Total[(s1-Mean[s1])^2/Length[s1]]]
N[Variance[s1]]

実行結果:
f:id:ti-nspire:20180510044758p:plain:w300
(Variance[] は不偏標本分散)
―――――――――――――――――――――――――――――――――
Excel の場合:
構文: VAR.P(始点セル:終点セル)
f:id:ti-nspire:20180508145916p:plain:w300
(VAR.S() は不偏標本分散)