Learn R Programming

mappeR (version 2.0.2)

create_balls: Make a cover of balls

Description

Make a cover of balls

Usage

create_balls(data, dists, eps)

Value

A list of vectors of data point names, one list element per ball. The output is such that every data point is contained in a ball of radius \(\varepsilon\), and no ball center is contained in more than one ball. The centers are datapoints themselves.

Arguments

data

A data frame.

dists

A distance matrix for the data frame.

eps

A positive real number.

Examples

Run this code
num_points = 5000

P.data = data.frame(
  x = sapply(1:num_points, function(x)
    sin(x) * 10) + rnorm(num_points, 0, 0.1),
  y = sapply(1:num_points, function(x)
    cos(x) ^ 2 * sin(x) * 10) + rnorm(num_points, 0, 0.1),
  z = sapply(1:num_points, function(x)
    10 * sin(x) ^ 2 * cos(x)) + rnorm(num_points, 0, 0.1)
)

P.dist = dist(P.data)
balls = create_balls(data = P.data, dists = P.dist, eps = .25)

Run the code above in your browser using DataLab