rgamma0 {ADtools}R Documentation

Simulate gamma random variates

Description

Simulate gamma random variates

Usage

rgamma0(n, shape, scale, method = "inv_tf")

Arguments

n

Positive integer; the number of samples.

shape

Positive number; the shape of the gamma distribution.

scale

Positive number; the scale of the gamma distribution.

method

'base' or 'inv_tf'; 'base' refers to 'stats::rgamma' while 'inv_tf' refers to inverse transform.

Note

Inverse transform is slower, but it is provided to remedy that base R uses two algorithms to simulate gamma random variables in different parameter regions, which creates a discontinuity in the pathwise derivative.

Examples

n <- 10
rgamma0(n, shape = 1, scale = 1)


[Package ADtools version 0.5.5 Index]