【问题标题】:Plotting series of pdfs and cdfs with different parameters绘制具有不同参数的一系列 pdf 和 cdf
【发布时间】:2021-04-01 22:53:36
【问题描述】:

我希望在 R 中重现类似于 this image 的内容。我的目标是在 Rayleigh 和其他具有不同参数的分布的同一张图上绘制一系列 pdf 和/或 cdfs。理想情况下,我想将相同的 x 值序列以及一系列参数值强制转换为数据框,然后使用 ggplot 进行绘制。

到目前为止,我已经尝试了以下几种排列方式:

"Scale

解决此问题的最佳方法是什么?我使用 for 循环和 rep(seq(...)) 进行了一些尝试,但没有成功。谢谢。

【问题讨论】:

  • 严格来说,这个问题在这里是题外话,因为它主要强调编程。我将尝试使用 R 的基础提供骨架代码,并将 ggplot 留给您。

标签: r data-visualization ggplot2


【解决方案1】:

具有尺度参数 $\sigma,$ 的瑞利分布有 密度函数 $f(x) = \frac{x}{\sigma^2}\exp\left[-.5(\frac{x^2}{\sigma^2 })\right],$ for $x,\sigma > 0.$ 如果在 R 的基础上绘制密度函数,则 酌情使用dnormdgamma等。 [程序curve 需要一个 x中的论据。]

m = 5;  sg = c(.5,1,2,3,4)
frb=c("blue", "darkgreen", "red", "cyan4", "purple")
hdr="Densities of Rayleigh Distributions: Scale = 0.5, 1, 2, 3, 4"
plot(c(0,11),c(0,1.2), col="white", ylab="Density", xlab="x", main=hdr)
 abline(h=0, col="grey");  abline(v=0, col="grey")
for(i in 1:m) {
 curve((x/sg[i]^2)*exp(-.5*(x^2/sg[i]^2)), add=T, col=frb[i])
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多