
Last chance! 50% off unlimited learning
Sale ends in
Pack unuran
object in package Runuran and report its
status (packed/unpacked).
Packed unuran
objects can be saved and loaded or sent to other
nodes in a computer cluster (which is not possible for unpacked
object).
FIXME
# S4 method for unuran
unuran.packed(unr)
unuran.packed(unr) <- value
a unuran
object.
TRUE
to pack the object.
Currently only objects that implement method ‘PINV’ can be packed.
A unuran
object contains a pointer to an external object in
library UNU.RAN. Thus it cannot be saved and restored in later R
sessions, nor is it possible to copy such an object to different nodes
in a computer cluster.
By “packing” an unuran
object all required data are
copied from the external object into an R list and stored in the
unuran
object while the external UNU.RAN object is
destroyed. Thus the object can be handled like any other R
object. Moreover, it can be still used as argument for
ur
and uq
(which may have even faster
execution times then).
Packed unuran
objects cannot be unpacked any more.
Notice that currently only objects that implement method ‘PINV’ can be packed.
unuran
, pinv.new
.
## create a unuran object for half-normal distribution using methed 'PINV'
gen <- pinv.new(dnorm,lb=0,ub=Inf)
## status of object
unuran.packed(gen)
## draw a random sample of size 10
x <- ur(gen,10)
## pack unuran object
unuran.packed(gen) <- TRUE
unuran.packed(gen)
## draw a random sample of size 10
x <- ur(gen,10)
if (FALSE) {
## unpacking is not supported
unuran.packed(gen) <- FALSE ## results in error
}
Run the code above in your browser using DataLab