% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/embedding.R
\name{sample_sphere_surface}
\alias{sample_sphere_surface}
\title{Sample vectors uniformly from the surface of a sphere}
\usage{
sample_sphere_surface(dim, n = 1, radius = 1, positive = TRUE)
}
\arguments{
\item{dim}{Integer scalar, the dimension of the random vectors.}

\item{n}{Integer scalar, the sample size.}

\item{radius}{Numeric scalar, the radius of the sphere to sample.}

\item{positive}{Logical scalar, whether to sample from the positive orthant
of the sphere.}
}
\value{
A \code{dim} (length of the \code{alpha} vector for
\code{sample_dirichlet()}) times \code{n} matrix, whose columns are the sample
vectors.
}
\description{
Sample finite-dimensional vectors to use as latent position vectors in
random dot product graphs
}
\details{
\code{sample_sphere_surface()} generates uniform samples from \eqn{S^{dim-1}}
(the \code{(dim-1)}-sphere) with radius \code{radius}, i.e. the Euclidean
norm of the samples equal \code{radius}.
}
\section{Related documentation in the C library}{
\href{https://igraph.org/c/html/0.10.17/igraph-Nongraph.html#igraph_sample_sphere_surface}{\code{sample_sphere_surface()}}
}

\examples{
lpvs.sph <- sample_sphere_surface(dim = 10, n = 20, radius = 1)
RDP.graph.3 <- sample_dot_product(lpvs.sph)
vec.norm <- apply(lpvs.sph, 2, function(x) {
  sum(x^2)
})
vec.norm
}
\seealso{
Other latent position vector samplers: 
\code{\link{sample_dirichlet}()},
\code{\link{sample_sphere_volume}()}
}
\concept{latent position vector samplers}
