LoginSignup
2
2

More than 5 years have passed since last update.

連続型確率分布を可視化する

Last updated at Posted at 2014-07-09

以前に書いた連続確率分布について R を利用して可視化してみます。

コード

n = 1000
df = 1
shape = 1
shape1 = 1
shape2 = 1
rate = 10
df1 = 10
df2 = 20

draw <- function (x, image) {
  png(image, width = 480, height = 480, pointsize = 12, bg = "white", res = NA)
  hist(x)
  dev.off()
}

x = runif(n, min=0, max=1)
draw(x, 'runif.png')
x = rnorm(n, mean=0, sd=1)
draw(x, 'rnorm.png')
x = rlnorm(n, meanlog = 0, sdlog = 1)
draw(x, 'rlnorm.png')
x = rgamma(n, shape, rate = 1, scale = 1/rate)
draw(x, 'rgamma.png')
x = rbeta(n, shape1, shape2)
draw(x, 'rbeta.png')
x = rchisq(n, df, ncp=0)
draw(x, 'rchisq.png')
x = rt(n, df)
draw(x, 'rt.png')
x = rf(n, df1, df2)
draw(x, 'rf.png')
x = rcauchy(n, location = 0, scale = 1)
draw(x, 'rcauchy.png')
x = rcauchy(n, location = 0, scale = 1)
draw(x, 'rcauchy.png')
x = rexp(n, rate = 1)
draw(x, 'rexp.png')
x = rlogis(n, location = 0, scale = 1)
draw(x, 'rlogis.png')
x = rweibull(n, shape, scale = 1)
draw(x, 'rweibull.png')

連続一様分布

runif.png

正規分布

rnorm.png

対数正規分布

rlnorm.png

ガンマ分布

rgamma.png

ベータ分布

rbeta.png

カイ二乗分布

rchisq.png

t 分布

rt.png

F 分布

rf.png

コーシー分布

rcauchy.png

指数分布

rexp.png

ロジスティック分布

rlogis.png

ワイブル分布

rweibull.png

まとめ

可視化してみると確率分布についてのイメージがよりとらえやすくなったかと思います。

参考

R の確率分布システム
http://www.okada.jp.org/RWiki/?R%A4%CB%A4%AA%A4%B1%A4%EB%B3%CE%CE%A8%CA%AC%C9%DB

確率分布と乱数
http://cse.naro.affrc.go.jp/takezawa/r-tips/r/60.html

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2