Evaluate the moment generating function (MGF) of the mixed gamma distribution or a derivative of the MGF

MGFmixedgamma(x, prob, rate, shape, deriv = 0)

Arguments

x

The value at which to evaluate the MGF

prob

A vector of probabilities of following each gamma distribution in the mixture

rate

A vector of rate parameter values for each gamma distribution in the mixture

shape

A vector of shape parameter values for each gamma distribution in the mixture

deriv

An integer, the number of derivatives of the MGF to apply

Value

The number resulting from the function evaluation

Examples

# MGF of a 40/60 mixture of two gamma distributions, evaluated at -0.1:
MGFmixedgamma(-0.1, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3))
#> [1] 0.759724
# Second moment of the distribution (second derivative evaluated at zero):
MGFmixedgamma(0, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3), deriv = 2)
#> [1] 16.56888