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.8762237 0.8026361 0.9955608 0.7425849 0.9639698 0.7855192 0.9901303
#> [8] 0.9732401 0.9814795 0.9916288 0.5922845 0.9314004 0.9082884 0.3507944
#> [15] 0.8538581 0.6559975 0.7455444 0.7918049 0.7400789 0.9835074