Skip to content

Commit

Permalink
generate() now respects dimnames for multivariate distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Sep 15, 2024
1 parent 143d764 commit 78ee386
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
34 changes: 18 additions & 16 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# distributional (development version)

## New features

* `support()` now shows whether the interval of support is open or
closed (@venpopov, #97)

### Probability distributions

* Added `dist_gk()` for g-and-k distributions.
* Added `dist_gh()` for g-and-h distributions.
* Added `dist_gev()` for the Generalised Extreme Value distribution and
`dist_gpd()` for the Generalised Pareto distribution (@robjhyndman, #124).

## Improvements

* `dist_mixture()` now displays the components of the mixture when the output
width is sufficiently wide (@statasaurus, #112).
* `generate()` now respects `dimnames()` for multivariate distributions.

## Bug fixes

* Fixed error when using '-' as a unary operator on a distribution different from
Expand All @@ -15,22 +33,6 @@
* The `quantile()` method for `dist_multivariate_normal()` now correctly gives
the boundaries when `p=0` or `p=1` when `type="equicoordinate"`.

## New features

* `support()` now shows whether the interval of support is open or
closed (@venpopov, #97)
* Added `dist_gev()` for the Generalised Extreme Value distribution and
`dist_gpd()` for the Generalised Pareto distribution (@robjhyndman, #124).

### Probability distributions

* Added `dist_gk()` for g-and-k distributions.
* Added `dist_gh()` for g-and-h distributions.

## Improvements

* `dist_mixture()` now displays the components of the mixture when the output
width is sufficiently wide (@statasaurus, #112).

## Breaking changes

Expand Down
4 changes: 3 additions & 1 deletion R/distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ log_cdf.distribution <- function(x, q, ...){
generate.distribution <- function(x, times, ...){
times <- vec_cast(times, integer())
times <- vec_recycle(times, size = length(x))
dn <- dimnames(x)
x <- vec_data(x)
dist_is_na <- vapply(x, is.null, logical(1L))
x[dist_is_na] <- list(structure(list(), class = c("dist_na", "dist_default")))
mapply(generate, x, times = times, ..., SIMPLIFY = FALSE)
mapply(function(x, ...) `colnames<-`(generate(x, ...), dn),
x, times = times, ..., SIMPLIFY = FALSE)
# dist_apply(x, generate, times = times, ...)
# Needs work to structure MV appropriately.
}
Expand Down

0 comments on commit 78ee386

Please sign in to comment.