Skip to contents

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))

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.

Value

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

Examples

dim <- n <- 3
(dist <- runif(1))
#> [1] 0.9192993
(center <- rnorm(dim))
#> [1]  1.7727061 -0.2132694 -0.7574294
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
#>           [,1]       [,2]       [,3]
#> [1,]  2.273109  1.5225045  1.5225045
#> [2,] -0.301729  0.2290287 -0.5671079
#> [3,] -0.910646 -0.9106460 -0.4509963
rowMeans(V)
#> [1]  1.7727061 -0.2132694 -0.7574294
dist(t(V))
#>           1         2
#> 2 0.9192993          
#> 3 0.9192993 0.9192993