draws_of | R Documentation |
Gets/sets the array-representation that backs an rvar
. Should be used rarely.
draws_of(x, with_chains = FALSE)
draws_of(x, with_chains = FALSE) <- value
x |
(rvar) An |
with_chains |
(logical) Should the array of draws include a dimension for chains?
If |
value |
(array) An array of values to use as the backing array of |
While rvar
s implement fast versions of basic math operations (including
matrix multiplication), sometimes you may need to bypass
the rvar
abstraction to do what you need to do more efficiently.
draws_of()
allows you to get / set the underlying array of draws in
order to do that.
rvar
s represent draws internally using arrays of arbitrary dimension, which
is returned by draws_of(x)
and can be set using draws_of(x) <- value
.
The first dimension of these arrays is the index of the draws. If
with_chains = TRUE
, then the dimensions of the returned array are modified
so that the first dimension is the index of the iterations and the second
dimension is the index of the chains.
If with_chains = FALSE
, an array with dimensions c(ndraws(x), dim(x))
.
If with_chains = TRUE
, an array with dimensions
c(niterations(x), nchains(x), dim(x))
.
x <- rvar(1:10, nchains = 2)
x
# draws_of() without arguments will return the array of draws without
# chain information (first dimension is draw)
draws_of(x)
# draws_of() with with_chains = TRUE will reshape the returned array to
# include chain information in the second dimension
draws_of(x, with_chains = TRUE)
# you can also set draws using draws_of(). When with_chains = FALSE the
# existing chain information will be retained ...
draws_of(x) <- 2:11
x
# when with_chains = TRUE the chain information will be set by the
# second dimension of the assigned array
draws_of(x, with_chains = TRUE) <- array(2:11, dim = c(2,5))
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.