Description Usage Arguments Value Methods (by class) Examples
This function computes and returns the distance matrix computed by using the specified distance measure to compute the pairwise distances between data points in a data set.
1 2 3 4 5 6 7 8 9 10 11 |
x |
Either a numeric matrix, a data frame, a |
method |
the distance measure to be used. This must be one of
|
diag |
logical value indicating whether the diagonal of the
distance matrix should be printed by |
upper |
logical value indicating whether the upper triangle of the
distance matrix should be printed by |
p |
The power of the Minkowski distance. |
dist
returns an object of class "dist"
.
The lower triangle of the distance matrix stored by columns in a
vector, say do
. If n
is the number of
observations, i.e., n <- attr(do, "Size")
, then
for i < j ≤ n, the dissimilarity between (row) i and j is
do[n*(i-1) - i*(i-1)/2 + j-i]
.
The length of the vector is n*(n-1)/2, i.e., of order n^2.
The object has the following attributes (besides "class"
equal
to "dist"
):
Size |
integer, the number of observations in the dataset. |
Labels |
optionally, contains the labels, if any, of the observations of the dataset. |
Diag, Upper |
logicals corresponding to the arguments |
call |
optionally, the |
method |
optionally, the distance method used; resulting from
|
default
: This is the dist
function of the
stats package. We refer the user to the corresponding documentation
for more details on the available distances and examples.
sgd
: Implementation for Single Gaussian Data (stored in objects
of class sgd
).
gmd
: Implementation for Gaussian Mixture Data (stored in objects
of class gmd
).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | x <- sgd(
c(mean = 0, precision = 1 ),
c(mean = 3, precision = 0.5),
c(mean = -1, precision = 2 )
)
dist(x)
N <- 100
M <- 4
w <- matrix(runif(N * M), N, M)
w <- w / rowSums(w)
s <- tidyr::crossing(
observation = paste0("O", 1:N),
component = paste0("C", 1:M)
) %>%
dplyr::mutate(mixing = as.numeric(t(w)))
d <- tibble::tibble(
component = paste0("C", 1:M),
mean = numeric(M),
precision = 1:M
)
y <- gmd(s, d)
dist(y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.