Learn R Programming

oeli (version 0.7.5)

equidistant_vectors: Generate equidistant vectors in Euclidean space

Description

This function constructs the coordinates of vertices of a regular simplex in \(\mathbb{R}^{\code{dim}}\) and returns the first n of them,

  • scaled so that the pairwise Euclidean distance between any two vertices equals dist,

  • and centered so their centroid is at center.

Usage

equidistant_vectors(dim, n = dim + 1, dist = 1, center = rep(0, dim))

Value

A matrix, where each column is a vertex of the simplex.

Arguments

dim

[integer(1)]
The dimension.

n

[integer(1)]
The number of vertices to return. Cannot be larger than dim + 1.

dist

[numeric(1)]
Desired pairwise Euclidean distance between any two vertices.

center

[numeric(dim)]
Desired center.

See Also

Other vector helpers: check_numeric_vector(), check_probability_vector(), chunk_vector(), insert_vector_entry(), map_indices(), match_numerics(), permutations(), split_vector_at(), subsets(), vector_occurrence()

Examples

Run this code
dim <- n <- 3
(dist <- runif(1))
(center <- rnorm(dim))
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
rowMeans(V)
dist(t(V))

Run the code above in your browser using DataLab