自由度=3
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x) # 常態分佈
y <- dt(x, df=3)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

自由度=10
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x)
y <- dt(x, df=10)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

自由度=100
x <- seq(-pi*2, 2*pi, .05)
z <- dnorm(x)
y <- dt(x, df=100)
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
lines(x, y, col='cadetblue')

自由度越大越趨近常態分布
參考黃凱揚同學
#
##seq()快速產生向量函數
x <- seq(-pi*2, 2*pi, .05)
##dnorm表現常態分配在 x 的機率密度函數值
z <- dnorm(x)
##T分佈中,x 所對應的密度
y <- dt(x, df=100)
##以X和Z畫圖, bty可以取6種字元,不同字元代表6種邊框。
plot(x, z, type="l", bty="L", xlab="Standard unit", ylab="Density")
##面積函數畫出 polygon() 可以用來繪製圖形,rev()將整個向量倒過來排,col設定顏色淺藍
polygon(c(x, rev(x)), c(y, rev(z)), col='aliceblue')
##lines加上直線
lines(x, y, col='cadetblue')
