Learn R Programming

PACBO (version 0.1.0)

labels_function: Label Caculation Function

Description

This function gives cluster label to each of the observations.

Usage

labels_function(centers, observations)

Arguments

centers
a matrix containing m centers of length d, where each row corresponds to coordinates of a center.
observations
a matrix containing T observations of length d, where each row of the matrix is an observation of length d.

Value

cluster label of each of the observations.

Details

Given a set C of m centers of length d (i.e., C = ${c_{1}, c_{2}, \dots, c_{m}}$), and a set X of T observations of length d (i.e., X = ${x_{1}, x_{2}, \dots, x_{T}}$), this function associates each observation $x_{t}$ to the nearest centers to form different cells, and gives a corresponding cluster label to it.

Examples

Run this code
## generating 4 centers of length 3.
centers <- matrix(1:12, nrow = 4, ncol = 3)
## generating 10 observations of length 3.
observations <- matrix(rmnorm(10, mean = c(2,6,10), varcov = diag(1,3)), nrow = 10)
labels_function(centers, observations)

Run the code above in your browser using DataLab