rsphere: Random vectors on a sphere

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Generates a sample of points uniformly distributed on the surface of a sphere in d-space.

Usage

1
rsphere(n, d)

Arguments

n

an integer, the sample size.

d

an integer, the dimension of the space. For example, a circle is defined in 2D-space, a sphere in 3D-space.

Details

The algorithm is based on normalizing to length 1 each d-vector of a sample from a multivariate normal N(0, I).

Value

a matrix of n rows and d columns.

Author(s)

Giovanni M. Marchetti

See Also

rnorm, rcorr

Examples

1
2
3
4
5
6
7
## 100 points on circle
z <- rsphere(100,2)
plot(z)

## 100 points on a sphere
z <- rsphere(100, 3)
pairs(z)

ggm documentation built on March 26, 2020, 7:49 p.m.

Related to rsphere in ggm...