我是 R 的新手,我的问题可能有点愚蠢,但感谢您提供任何帮助。我想以图形方式探索样本以找到可以从中提取样本的适当分布。但是当我绘制样本的直方图时,样本的密度超过了 1 的理论最大值:
如何调整此错误?我需要转换数据还是必须调整直方图的 bin?
我的 R 代码:
dataSample = read.table("sample6.txt", fill = TRUE)
sampleMatrix = as.matrix(dataSample)
sampleVector = as.vector(sampleMatrix)
h = hist(sampleVector, plot=F)
x =c(min(sampleVector, na.rm=T), max(sampleVector, na.rm=T))
ylim = range(0, max(get("density", h), max(density)))
hist(sampleVector, prob = T, col = "lightgreen", xlim = x,
ylim = ylim, main = "Histogram of data sample", xlab = "sample", ylab = "density")
这是我的数据样本:
0.5604785 0.0231508 0.2715692 0.2464922 0.2743465
0.434444 0.1779845 1.163666 0.5195378 0.08565649
0.2003622 0.3372351 0.02383633 0.2765776 0.1596984
0.3688299 0.2727399 0.3578011 0.4405475 0.07207568
0.424764 1.406219 1.12157 2.170512 0.6944183
2.429551 0.889546 0.1930762 0.579666 0.06834702
0.03690897 0.391838 1.019549 0.272865 0.1993042
0.02951076 0.3739699 0.2612313 1.988982 1.100386
0.9509101 1.978394 0.2469858 0.1256963 1.645895
0.1024105 0.336701 0.1322722 0.3881196 1.152153
0.6207026 1.506684 0.2826296
提前致谢!