我想创建3个图表用于说明目的: - 正常分配 - 右倾斜分布 - 左偏分布
这应该是一项简单的任务,但我发现只有this link,它只显示正态分布。我该怎么办呢?
答案 0 :(得分:25)
如果你不太正常,那么我建议你使用beta分布,它可以是对称的,右倾斜的,或者根据形状参数左倾斜。
hist(rbeta(10000,5,2))
hist(rbeta(10000,2,5))
hist(rbeta(10000,5,5))
答案 1 :(得分:13)
最后我得到了它,但是在你的帮助下,我依靠this site。
N <- 10000
x <- rnbinom(N, 10, .5)
hist(x,
xlim=c(min(x),max(x)), probability=T, nclass=max(x)-min(x)+1,
col='lightblue', xlab=' ', ylab=' ', axes=F,
main='Positive Skewed')
lines(density(x,bw=1), col='red', lwd=3)
这也是一个有效的解决方案:
curve(dbeta(x,8,4),xlim=c(0,1))
title(main="posterior distrobution of p")
答案 2 :(得分:10)
只需使用fGarch
包和这些功能:
dsnorm(x, mean = 0, sd = 1, xi = 1.5, log = FALSE)
psnorm(q, mean = 0, sd = 1, xi = 1.5)
qsnorm(p, mean = 0, sd = 1, xi = 1.5)
rsnorm(n, mean = 0, sd = 1, xi = 1.5)
** mean,sd,xi location parameter mean,scale parameter sd,skewness parameter xi。 实例
## snorm -
# Ranbdom Numbers:
par(mfrow = c(2, 2))
set.seed(1953)
r = rsnorm(n = 1000)
plot(r, type = "l", main = "snorm", col = "steelblue")
# Plot empirical density and compare with true density:
hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue")
box()
x = seq(min(r), max(r), length = 201)
lines(x, dsnorm(x), lwd = 2)
# Plot df and compare with true df:
plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue",
ylab = "Probability")
lines(x, psnorm(x), lwd = 2)
# Compute quantiles:
round(qsnorm(psnorm(q = seq(-1, 5, by = 1))), digits = 6)