Skip to contents

Sample finite-dimensional vectors to use as latent position vectors in random dot product graphs

Usage

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

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.6402338 0.6593752 0.9544890 0.9339933 0.9203130 0.7648080 0.5012996
#>  [8] 0.9130866 0.9040643 0.7459550 0.7993205 0.8501502 0.4005628 0.9181464
#> [15] 0.8796855 0.6619238 0.9693595 0.9643994 0.5022496 0.9079641