ChaoranHu / coga

R package for Convolution of Gamma Distributions
GNU General Public License v3.0
4 stars 1 forks source link

What about a `qcoga` function? #4

Closed samorso closed 1 year ago

samorso commented 4 years ago

Hey, Thanks for your package, it is very useful for my research. I was wondering whether you plan and how easy it would be to implement a qcoga function for the quantiles of convolution of independent gamma random variables. I think that would be useful function, most distributions in R have a quantile function. Right now I am using this code

qcoga0 <- function(p, shape, rate){
  uniroot(f=function(x)pcoga(x,shape,rate)-p, lower = 1e-4, upper = 1e4)$root
}
qcoga <- Vectorize(qcoga0,vectorize.args = "p")

Maybe you have a better idea on how to implement an efficient version? Best, Sam

ChaoranHu commented 1 year ago

Sorry for the extremely late reply, @samorso! Your question is very interesting. We did also investigate it before but unfortunately not found anything interesting. So, we do not have a better way to do this task for now other than what implemented in your code. I will find some time and try to include your function in this package in future!

--C.Hu