跳到内容

采样有限维向量以用作随机点积图中的潜在位置向量

用法

sample_sphere_surface(dim, n = 1, radius = 1, positive = TRUE)

参数

dim

整数标量,随机向量的维度。

n

整数标量,样本大小。

半径

数值标量,球体的采样半径。

positive

逻辑标量,是否从球体的正象限采样。

一个 dimsample_dirichlet()alpha 向量的长度)乘以 n 的矩阵,其列是样本向量。

详细信息

sample_sphere_surface() 从 \(S^{dim-1}\) ((dim-1)-球体) 生成均匀样本,半径为 radius,即样本的欧几里德范数等于 radius

参见

其他潜在位置向量采样器:sample_dirichlet(), sample_sphere_volume()

示例

lpvs.sph <- sample_sphere_surface(dim = 10, n = 20, radius = 1)
RDP.graph.3 <- sample_dot_product(lpvs.sph)
vec.norm <- apply(lpvs.sph, 2, function(x) {
  sum(x^2)
})
vec.norm
#>  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1