### t分布のグラフィクス

MINAKA Nobuhiro — Nov 4, 2013, 2:28 PM

``````## t分布に関連する関数（dchisq, pchisq, qchisq, rchisq）

# —————————————————————————————————
# ｔ分布の密度関数（dt）を表示し，標準正規分布と比較
# —————————————————————————————————

x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")
``````

``````
# —————————————————————————————————
# 1％点の表示
# —————————————————————————————————
x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")

abline(h=0.05)
lower.alpha5 <- qt(0.05, 5)
lower.alpha5
``````
``````[1] -2.015
``````
``````abline(v=lower.alpha5)
points(lower.alpha5, 0.05, cex=3.0, pch="*")

upper.alpha5 <- -lower.alpha5
upper.alpha5
``````
``````[1] 2.015
``````
``````abline(v=upper.alpha5)
points(upper.alpha5, 0.05, cex=3.0, pch="*")
``````

``````
# —————————————————————————————————
# t分布のパラメーター――自由度を変える
# —————————————————————————————————

x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")
title("t Distribution\ndf=1 to 10")
for (i in 1:5) curve(dt(x, i), type="l", lty=i, add=T)
``````

``````
# Original Script: 8 December 2004 by MINAKA Nobuhiro