Skip to content

Commit

Permalink
Fixed dist_gamma() not allowing the scale parameter to be used
Browse files Browse the repository at this point in the history
Resolves #132
  • Loading branch information
mitchelloharawild committed Jan 4, 2025
1 parent 683b96e commit 9d88185
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion R/dist_gamma.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 9d88185

Please sign in to comment.