Learn R Programming

facilityepimath (version 0.1.0)

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

Description

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

Usage

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

Value

The number resulting from the function evaluation

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

Examples

Run this code
# 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))
# 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)

Run the code above in your browser using DataLab