dist
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
Compute the variance, covariance or covariance-matrix.
- Usage 1
dist(xscalar, yscalar)
dist(xvector, yvector)
- Result 1
- The euclidan distance dscalar of x and y. The two arguments must be scalars or vectors with the same length.
- Usage 2
dist(xvector)
dist(xmatrix)
- Result 2
- The distance matrix d with the euclidian distances of all elements or row vectors of x. The result is a matrix with
nrow(x)
rows and columns.
-> d[i,j] = dist(x[i], x[j]) -> di,j = dist(x[i,*], x[j,*])
- Usage 2
dist(x)
- Result 2
The covariance v of the vectors x and y.
v = sum( (x-avr(x) ?* (y-avr(y)) ) / (nrow(x)-1)
v = ((x-avr(x) * (y-avr(y))) / (nrow(x)-1)
- Usage 3
var(xmatrix)
var(xmatrix, yscalar)
var(xmatrix, yvector)
- Result 3
- The covariance matrix v of the column vectors of x.
v[i,j] = sum( (x[*,i]-a[i]) ?* (x[*,j]-a[j]) ) / (nrow(x)-1) , with: i,j = 0..ncol(x)-1
- The column averages a[i] are computed as follows:
y not supplied a[i] = avr(x[*,i]) yscalar a[i] = y yvector a[i] = y[i]
dist
Calculate the distance matrix for all elements in the vector x or for all row vectors in the matrix x. I.e. d(i,j) = distance (x[i,*], x[j,*]). This is a subcommand of the EVAL
command.
Usage:
dist(x)
Return Type:
matrix
Calculate the Euclidean distance from x to y. Both arguments must be either scalars or vectors.
Usage:
dist(x, y)
Return Type:
scalar
Calculate the Euclidean distances between all elements of xv or all row vectors of xm to the value ys or the vector yv. The result is a vector with x[!nrow] elements.
Usage:
dist(xv,ys)
dist(xm, yv)
Return Type:
vector