Learn R Programming

cardinalR (version 1.0.6)

make_shape_para: Generate Parallel Multi-Shape Clusters

Description

This function generates synthetic high-dimensional data consisting of \(k\) clusters of a specified shape (e.g., crescents), arranged in parallel along alternating dimensions. The first cluster is shifted along the first dimension, the second along the third dimension, the third along the first dimension again, and so on.

Usage

make_shape_para(n = c(500, 300), k = 2, shift = 1, shape = "crescent")

Value

A tibble containing \(\sum n\) rows and \(p\) columns, with the generated features (`x1, x2, x3, x4`) and a `cluster` label.

Arguments

n

A numeric vector of length \(k\), specifying the number of observations in each cluster. All values must be positive.

k

Integer. Number of clusters to generate. Must be greater than 1.

shift

Numeric. The distance between cluster centers along the alternating dimensions (default is `0.4`).

shape

Character string. Shape of the clusters to generate (e.g., `"crescent"`, `"gridcube"`, etc.). Must be a single value.

Examples

Run this code
# Generate 2 crescent-shaped clusters in 4D
twocrescent <- make_shape_para(n = c(500, 300), k = 2, shape = "crescent")


Run the code above in your browser using DataLab