diff --git a/NEWS.md b/NEWS.md index 735321a3..f415eb6a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,10 @@ * Transformed distributions now work better for monotonic increasing functions when the domain of the untransformed distribution is R (#129). +## Bug fixes + +* Fixed `dist_gamma()` not allowing the `scale` parameter to be used (#132). + ## Breaking changes * The `quantile()` method for `dist_multivariate_normal()` now defaults to diff --git a/R/dist_gamma.R b/R/dist_gamma.R index 7ed5464c..3328e41f 100644 --- a/R/dist_gamma.R +++ b/R/dist_gamma.R @@ -80,8 +80,11 @@ #' #' @name dist_gamma #' @export -dist_gamma <- function(shape, rate, scale = 1/rate){ +dist_gamma <- function(shape, rate = 1/scale, scale = 1/rate){ shape <- vec_cast(shape, double()) + if(missing(rate) && missing(scale)) { + abort("Either the `rate` or `scale` must be specified for Gamma distributions.") + } rate <- vec_cast(rate, double()) if(any(shape[!is.na(shape)] < 0)){ abort("The shape parameter of a Gamma distribution must be non-negative.")