View source: R/truncated_distributions.R
| rgammat | R Documentation |
Generates random observations from a gamma distribution
truncated to the interval (lower, upper) using inverse transform
sampling.
rgammat(n, shape, scale, lower, upper)
n |
Integer. Number of observations to generate. |
shape |
Numeric. Shape parameter of the gamma distribution. |
scale |
Numeric. Scale parameter of the gamma distribution. |
lower |
Numeric. Lower truncation bound. |
upper |
Numeric. Upper truncation bound. |
Random values are generated by sampling from a uniform distribution on the
interval [F(lower), F(upper)], where F is the CDF of the gamma
distribution, and then applying the inverse CDF.
This approach ensures that the generated values follow the truncated distribution exactly.
The implementation is based on the inverse transform method as described in: https://www.r-bloggers.com/2020/08/generating-data-from-a-truncated-distribution/
A numeric vector of length n containing random draws from the
truncated gamma distribution.
Martin Haringa
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.