simplex_project_mat(p)

Arguments

p

number of vertices

Value

A matrix that transforms each vertices (column) to (p-1) dimensional space

Examples

A4 <- simplex_project_mat(4) # expected for dim 4 (for examples on wikipedia) A4_expected <- matrix(c(1,0,0, -1/3, sqrt(8)/3,0, -1/3,-sqrt(2)/3, sqrt(2/3), -1/3, -sqrt(2)/3, -sqrt(2/3)), ncol = 4) all.equal(A4, A4_expected) # minor numerical inconsistencies
#> [1] TRUE
library(dplyr) if (interactive()){ # visualizing this 4d projection s4in3 <- simplex_project_mat(4) %>% t %>% data.frame %>% rbind(., data.frame(X1 = 0, X2 = 0, X3 = 0)) %>% mutate(color = factor(c(rep(1,4), 2)))#center library(plotly) plot_ly(s4in3, type = "scatter3d", mode = "markers", x = ~X1, y = ~X2, z = ~X3, color = ~color) } # visualizing a 3d projection s3in2 <- simplex_project_mat(3) %>% t %>% data.frame %>% rbind(., data.frame(X1 = 0, X2 = 0)) %>% mutate(color = factor(c(rep(1,3), 2))) #center library(ggplot2) ggplot(s3in2) + geom_point(aes(x = X1, y = X2, color = color))