[英]Plotting gamma probability density function
我正在嘗試繪制R中的伽馬概率密度函數,其中對於(k = 1,μ= 1),(k = 2,μ= 1),(k = 2,μ= 2,y∈(0,10) )。 在R中
在R中,pgamma函數接受:
pgamma(q, shape, rate = 1, scale = 1/rate, alpha = shape, beta = scale, lower.tail = TRUE, log.p = FALSE)
在R中,我嘗試過:
pgamma(1,1,rate=1,scale = 1/rate, alpha = shape, beta = scale, lower.tail = True, log.p = False)
但是我得到消息
Error in pgamma(1, 1, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) :
object 'rate' not found
這是我第一次繪制伽馬分布,並希望對此有所幫助。
下圖使用基本R圖形繪制了三種密度。
首先,需要的參數值。 我假設您的mu
是Gamma發行版的Wikipedia頁面中定義的。
k <- c(1, 2, 2)
mu <- c(1, 1, 2)
theta <- mu/k
現在,情節。
plot(0, 0, xlim = c(0, 10), ylim = c(0, 1), type = "n")
for(i in seq_along(k))
curve(dgamma(x, shape = k[i], scale = theta[i]), from = 0, to = 10, col = i, add = TRUE)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.