Processing math: 100%
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 Sdim1 (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.5107383 0.9702620 0.9313446 0.7826239 0.9006161 0.9105936 0.2688683
#>  [8] 0.6761988 0.5461198 0.9849826 0.7700989 0.6592338 0.9190629 0.8928857
#> [15] 0.9870842 0.8720690 0.7226361 0.7508656 0.9817244 0.9408558