hypervolume_distance_point {hypervolume} | R Documentation |
Distance from a point to the margin of a hypervolume.
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.
Code by Clement Violet.
Usage
hypervolume_distance_point(hv1, x, type = "minimum",
num.points.max = 1000, check.memory = TRUE)
Arguments
hv1 |
A |
x |
An object coercible to a |
type |
If 'minimum', compute the smallest distance to the hypervolume margin; if 'maximum' calculates the greatest distance to the margin of the hypervolume. |
num.points.max |
The number of random points to subsample from the input hypervolume. |
check.memory |
If |
Details
Distance calculations scale quadratically with npmax
and may be computationally costly.
Value
The distance between the two hypervolumes.
Examples
## Not run:
data(penguins,package='palmerpenguins')
penguins_no_na = as.data.frame(na.omit(penguins))
penguins_adelie = penguins_no_na[penguins_no_na$species=="Adelie",
c("bill_length_mm","bill_depth_mm","flipper_length_mm")]
hv1 = hypervolume_gaussian(penguins_adelie)
point = penguins_no_na[penguins_no_na$species=="Chinstrap",
c("bill_length_mm","bill_depth_mm","flipper_length_mm")][42, ]
# note that minimum distance is smaller than centroid distance as expected
hypervolume_distance_point(hv1, point, type='minimum', num.points.max=500, check.memory=FALSE)
hypervolume_distance_point(hv1, point, type='maximum', num.points.max=500, check.memory=FALSE)
## End(Not run)