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.
hypervolume_distance(hv1, hv2, type = "centroid", npmax = 1000, check_memory = TRUE)
A Hypervolume
object.
A Hypervolume
object.
If 'centroid', the centroid distance; if 'minimum', the minimum distance.
The number of random points to subsample from each input hypervolume. Ignored if type='centroid'
.
If TRUE
, prints expected memory usage and returns an error before allocating memory. Ignored if type='centroid'
.
The distance between the two hypervolumes.
Minimum distance calculations scale quadratically with npmax
and may be computationally costly.
# NOT RUN {
data(iris)
hv1 = hypervolume(subset(iris, Species=="setosa")[,1:4],reps=1000,bandwidth=0.2,warn=FALSE)
hv2 = hypervolume(subset(iris, Species=="virginica")[,1:4],reps=1000,bandwidth=0.2,warn=FALSE)
# note that minimum distance is smaller than centroid distance as expected
hypervolume_distance(hv1, hv2, type='centroid')
hypervolume_distance(hv1, hv2, type='minimum', npmax=500, check_memory=FALSE)
# }
Run the code above in your browser using DataLab