Learn R Programming

bmixture (version 1.7)

mixgamma: Mixture of Gamma distribution

Description

Random generation and density function for a finite mixture of Gamma distribution.

Usage

rmixgamma( n = 10, weight = 1, alpha = 1, beta = 1 )

dmixgamma( x, weight = 1, alpha = 1, beta = 1 )

Arguments

n

number of observations.

x

vector of quantiles.

weight

vector of probability weights, with length equal to number of components (\(k\)). This is assumed to sum to 1; if not, it is normalized.

alpha

vector of non-negative parameters of the Gamma distribution.

beta

vector of non-negative parameters of the Gamma distribution.

Value

Generated data as an vector with size \(n\).

Details

Sampling from finite mixture of Gamma distribution, with density: $$Pr(x|\underline{w}, \underline{\alpha}, \underline{\beta}) = \sum_{i=1}^{k} w_{i} Gamma(x|\alpha_{i}, \beta_{i}),$$ where $$Gamma(x|\alpha_{i}, \beta_{i})=\frac{(\beta_{i})^{\alpha_{i}}}{\Gamma(\alpha_{i})} x^{\alpha_{i}-1} e^{-\beta_{i}x}.$$

References

Mohammadi, A., Salehi-Rad, M. R., and Wit, E. C. (2013) Using mixture of Gamma distributions for Bayesian analysis in an M/G/1 queue with optional second service. Computational Statistics, 28(2):683-700, 10.1007/s00180-012-0323-3

Mohammadi, A., and Salehi-Rad, M. R. (2012) Bayesian inference and prediction in an M/G/1 with optional second service. Communications in Statistics-Simulation and Computation, 41(3):419-435, 10.1080/03610918.2011.588358

See Also

rgamma, rmixnorm, rmixt

Examples

Run this code
# NOT RUN {
n      = 10000   
weight = c( 0.6  , 0.3  , 0.1   )
alpha  = c( 100  , 200  , 300   )
beta   = c( 100/3, 200/4, 300/5 )
    
data = rmixgamma( n = n, weight = weight, alpha = alpha, beta = beta )
  
hist( data, prob = TRUE, nclass = 30, col = "gray" )
  
x            = seq( -20, 20, 0.05 )
densmixgamma = dmixnorm( x, weight, alpha, beta )
      
lines( x, densmixgamma, lwd = 2 )
# }

Run the code above in your browser using DataLab