Learn R Programming

hypervolume (version 1.2.2)

expectation_convex: Convex expectation

Description

Creates a hypervolume with geometry of the convex polytope (hull) minimally enclosing a set of points

Usage

expectation_convex(input, 
  npoints_inhull = NULL, npoints_onhull = NULL,
  check_memory = TRUE, userandom = FALSE, 
  method = "rejection", burnin = NULL, delta = NULL)

Arguments

input
A data frame or hypervolume object whose data are enclosed by the output hypervolume.
npoints_inhull
Number of random points in the output hypervolume. If NULL and input is of class Hypervolume, defaults to a value that matches the point density of the input hypervolume; if NULL and input i
npoints_onhull
Number of data points to sample from the input to define the convex polytope. Samples are weighted by their Euclidean distance from the centroid of the input. If NULL, defaults to 10^sqrt(n).
check_memory
If TRUE, prints estimated memory usage and convex polytope size and exits. Otherwise contines the algorithm. Memory usage can be very high in high dimensions.
userandom
If input is a hypervolume and userandom is TRUE, the output hypervolume will enclose the uniformly random points defining the hypervolume; otherwise, it will enclose the data points used to build the hypervolume. If
method
If "rejection", constructs output hypervolume using hyperbox rejection sampling (recommended) from the convex polytope. If "metropolis", uses Metropolis-Hastings algorithm, discarding the first burnin samples with a
burnin
Number of MCMC samples to discard if method="metropolis". Defaults to 10^n (value not guaranteed to produce uniformly random results). Otherwise ignored.
delta
Jump size for MCMC sampling if method="metropolis". Defaults to one percent of the maximum range of the data along any axis. Otherwise ignored.

Value

  • A Hypervolume object containing a uniformly random set of points sampled from the convex polytope enclosing the input data.

Details

The computational complexity of convex polytope algorithms is very high. Running in n>5 dimensions may crash most desktop computers due to high memory requirements. Even if sufficient memory is available, rejection sampling becomes exponentially inefficient with dimensionality, resulting in long runtimes. The Metropolis-Hastings method may run faster in high dimensions but convergence to a uniformly random distribution may require very high burn-in values.

Examples

Run this code
# NOTE: uncomment next lines to try example (not run to pass CRAN runtime checks)

data(iris)

#hv1 = hypervolume(subset(iris, Species=="setosa")[,1:4],bandwidth=0.2)

#ec <- expectation_convex(hv1, userandom=F, check_memory=FALSE)
#plot(hypervolume_join(hv1, ec))

Run the code above in your browser using DataLab