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.3746926
(center <- rnorm(dim))
#> [1]  1.0369321 -0.7828198 -0.4083905
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
#>            [,1]       [,2]       [,3]
#> [1,]  1.2408889  0.9349537  0.9349537
#> [2,] -0.8188747 -0.6025458 -0.9270391
#> [3,] -0.4708392 -0.4708392 -0.2834929
rowMeans(V)
#> [1]  1.0369321 -0.7828198 -0.4083905
dist(t(V))
#>           1         2
#> 2 0.3746926          
#> 3 0.3746926 0.3746926