Rev Language Reference


fnDiscretizeGamma - Discretize a Gamma distribution

`fnDiscretizeGamma` approximates a continuous gamma distribution by dividing it into a specified number of discrete categories (quantiles), using either the mean or the median of each interval.

Usage

fnDiscretizeGamma(RealPos shape, RealPos rate, Integer numCats, Bool median)

Arguments

shape : RealPos (pass by const reference)
The shape parameter of the gamma distribution.
rate : RealPos (pass by const reference)
The rate parameter (rate = 1/scale) of the gamma distribution
numCats : Integer (pass by value)
The number of categories.
median : Bool (pass by value)
Should we use the median or mean?
Default : FALSE

Return Type

Details

This function takes a gamma distribution parameterized by `shape` and `rate`, along with a specified number of categories (`numCats`). It then discretizes the distribution into `numCats` bins yielding a sequence of values, assuming that each bin represents an equal probability mass. The representative values for each category can be chosen based on either the mean or the median of the interval.

Example

# to obtain the mean of the quantiles
alpha = 0.5

discrete_values := fnDiscretizeGamma( shape = alpha, rate = alpha, numCats = 4, median = FALSE )

See Also