Sample finite-dimensional vectors to use as latent position vectors in random dot product graphs
Arguments
- dim
Integer scalar, the dimension of the random vectors.
- n
Integer scalar, the sample size.
- radius
Numeric scalar, the radius of the sphere to sample.
- positive
Logical scalar, whether to sample from the positive orthant of the sphere.
Value
A dim
(length of the alpha
vector for
sample_dirichlet()
) times n
matrix, whose columns are the sample
vectors.
Details
sample_sphere_volume()
generates uniform samples from \(S^{dim-1}\)
(the (dim-1)
-sphere) i.e. the Euclidean norm of the samples is
smaller or equal to radius
.
See also
Other latent position vector samplers:
sample_dirichlet()
,
sample_sphere_surface()
Examples
lpvs.sph.vol <- sample_sphere_volume(dim = 10, n = 20, radius = 1)
RDP.graph.4 <- sample_dot_product(lpvs.sph.vol)
vec.norm <- apply(lpvs.sph.vol, 2, function(x) {
sum(x^2)
})
vec.norm
#> [1] 0.7688058 0.6585114 0.9551110 0.8593609 0.9989740 0.9987677 0.8974146
#> [8] 0.9730082 0.9656196 0.9356756 0.7363652 0.9339241 0.9183260 0.9686613
#> [15] 0.8277614 0.9508361 0.9275304 0.6914062 0.8031998 0.9770563