unuran.packed-methods: Pack "unuran" object

unuran.packed-methodR Documentation

Pack "unuran" object

Description

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

Usage

## S4 method for signature 'unuran'
unuran.packed(unr)
unuran.packed(unr) <- value

Arguments

unr

a unuran object.

value

TRUE to pack the object.

Details

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.

Methods

Currently only objects that implement method ‘PINV’ can be packed.

Note

Note that due to limitations of floating point arithmetic the output of a uq call with the same input value for u may slightly differ for the packed and unpacked version.

See Also

unuran, pinv.new.

Examples

## 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)

## Not run: 
## unpacking is not supported
unuran.packed(gen) <- FALSE    ## results in error 

## End(Not run)

Runuran documentation built on Jan. 17, 2023, 5:17 p.m.