Learn R Programming

hypervolume (version 2.0.12)

hypervolume_distance: Distance between two hypervolumes

Description

Calculates the distance between two hypervolumes either defined as the Euclidean distance between centroids or as the minimum Euclidean distance between the random points comprising either hypervolume.

Usage

hypervolume_distance(hv1, hv2, type = "centroid", 
  num.points.max = 1000, check.memory = TRUE)

Arguments

hv1

A Hypervolume object.

hv2

A Hypervolume object.

type

If 'centroid', the centroid distance; if 'minimum', the minimum distance.

num.points.max

The number of random points to subsample from each input hypervolume. Ignored if type='centroid'.

check.memory

If TRUE, prints expected memory usage and returns an error before allocating memory. Ignored if type='centroid'.

Value

The distance between the two hypervolumes.

Details

Minimum distance calculations scale quadratically with npmax and may be computationally costly.

Examples

Run this code
# NOT RUN {
data(iris)
hv1 = hypervolume_gaussian(subset(iris, Species=="setosa")[,1:3])
hv2 = hypervolume_gaussian(subset(iris, Species=="virginica")[,1:3])

# note that minimum distance is smaller than centroid distance as expected
hypervolume_distance(hv1, hv2, type='centroid')
hypervolume_distance(hv1, hv2, type='minimum', num.points.max=500, check.memory=FALSE)
# }

Run the code above in your browser using DataLab