Learn R Programming

MajKMeans (version 0.1.0)

Euclid: Euclidian distance

Description

Calculates the Euclidian distance between points. This function can use in kmeans function to do the clustering procedure using the Euclidian distance.

Usage

Euclid(x, mu)

Arguments

x

matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X))

mu

initial seleted centroids (randomly or another method).

Value

Euclidian distance between two points.

Examples

Run this code
# NOT RUN {
{
X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2))
M <- X[sample(nrow(X), 2),]
Euclid(X,M)
}
# }

Run the code above in your browser using DataLab