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.9247414 0.8693277 0.8569139 0.6147789 0.7752670 0.4860221 0.5923761
#>  [8] 0.9377279 0.8577889 0.5926572 0.7209531 0.7130781 0.7608810 0.7326042
#> [15] 0.7399899 0.8089262 0.5141588 0.9981022 0.8748003 0.9809762