Skip to content

rvar_sample() #2

@tjmahr

Description

@tjmahr
rvar_sample <- function(x, size, replace = FALSE, prob = NULL) {
  x_draws <- posterior::draws_of(x) 
  draws <- sample.int(dim(x_draws)[1], size, replace, prob)

  index_args <- c(
    list(x_draws),
    list(draws),
    dim(x_draws)[-1] |> as.list() |> lapply(seq_len)
  )

  do.call(`[`, index_args) |> posterior::rvar()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions