Skip to contents

Following Hallin et al. (2021) and the OT2.R reference code, builds a grid of n points on the unit ball \(S^d\) used as the target of the center-outward transform (center_outward_transform). The grid consists of:

  • n0 copies of the origin;

  • nR radial levels \(r_k = k/(n_R+1)\), \(k = 1, \ldots, n_R\), each carrying the same nS angular directions;

so that n0 + nR * nS = n. The nS directions are quasi-uniform unit vectors on \(S^{d-1}\) (equally spaced angles for d = 2, normalized Gaussian draws for d > 2, as in OT2.R).

Usage

build_ball_grid(n, d, nR, nS, n0, seed = 42)

Arguments

n

Integer: total number of grid points.

d

Integer: dimension of the ball.

nR

Integer: number of radial levels.

nS

Integer: number of angular directions per radial level.

n0

Integer: number of copies of the origin, so that n0 + nR * nS = n.

seed

Integer random seed for the quasi-uniform directions when d > 2 (unused for d <= 2, which are deterministic). The grid is reproducible for a given (nS, seed), since nS is folded into the seed actually used. Defaults to 42.

Value

Numeric matrix (n x d): rows are the grid points in the unit ball \(S^d\).

Examples

# n = n0 + nR * nS = 2 + 3 * 4
grid <- build_ball_grid(n = 14, d = 2, nR = 3, nS = 4, n0 = 2)
dim(grid)
#> [1] 14  2