#author("2020-05-21T07:51:54+09:00","default:ryuichi","ryuichi")
#author("2020-05-21T08:00:53+09:00","default:ryuichi","ryuichi")
* 標準偏差 - stddev_pop stddev_samp [#h1619375]

** 前提 [#v7aa798b]
 CREATE TABLE t6 (id int, n int);
 INSERT INTO t6 VALUES (1, 90), (2, 80), (3, 40), (4,60), (5, 90)
 SELECT * FROM t6;
 
  id | n
 ----+----
   1 | 90
   2 | 80
   3 | 40
   4 | 60
   5 | 90

** この例での標準偏差を求める [#u0e40fa7]
*** この例での標準偏差を求める [#qfe92abb]

#ref(deviation-value-202005.png)

- 平均値は ''72''
- 標準偏差は ''19.39071'' と求まった


** stddev_pop() - 母標準偏差 [#rdf5b414]

 SELECT AVG(n), stddev_pop(n) FROM t6;
 
          avg         |     stddev_pop
 ---------------------+---------------------
  72.0000000000000000 | 19.3907194296653161

** stddev_samp() 標本標準偏差 [#zd2394d2]

 SELECT stddev_samp(n) FROM t6;
 
      stddev_samp
 ---------------------
  21.6794833886787994

** 母標準偏差と標本標準偏差の違い [#be5e82f5]

> つまり簡単に特性だけ述べると
> 
> stddev_pop(標準偏差): 遅い、正確
> stddev_samp(標本標準偏差): 速い、不正確

- 参考 https://qiita.com/ironsand/items/a614fb9fc39cf89c2dcf
** 参考 [#d26a45b1]

- https://www.postgresql.org/docs/current/functions-aggregate.html
- https://to-kei.net/basic-study/basic/standard-deviation/

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS