Generic Pairwise Distance Computation
pairwise_dist.Rd
This function acts as a generic interface for computing pairwise distances between the rows of a matrix X. The actual computation is delegated to method-specific functions depending on the class of `dist_obj`.
Arguments
- X
A numeric matrix where each row is considered as a data point between which distances are to be calculated. The matrix should not contain any missing values as this may affect the accuracy and performance of the distance computations.
- ...
Additional arguments to be passed to the method-specific distance functions.
- dist_obj
A distance object which specifies the type of distance measure to be used and potentially contains additional parameters needed for distance calculation. The class of `dist_obj` determines which method is dispatched.
Value
Depending on the specific method implementation, this function typically returns a numeric matrix or an object of class `dist` representing the pairwise distances between the rows of `X`.
Details
`pairwise_dist` is a generic function meant to interface with various methods for distance computation. Users must provide a `dist_obj` which includes specifics about the distance measure to be used. The actual computation is handled by method-specific functions that should be defined for different classes of `dist_obj`. These functions must be registered with the appropriate S3 method for `pairwise_dist` such as `pairwise_dist.default`, `pairwise_dist.correlation`, etc.
See also
dist
for default distance computations in R.
Examples
# Assuming a correlation-based distance object and matrix X
dist_obj <- correlation_dist_object(parameters)
#> Error in correlation_dist_object(parameters): could not find function "correlation_dist_object"
X <- matrix(rnorm(100), ncol = 10)
distances <- pairwise_dist(dist_obj, X)
#> Error in eval(expr, envir, enclos): object 'dist_obj' not found