r_unif function

Sample uniformly distributed circular and spherical data

Sample uniformly distributed circular and spherical data

Simulation of the uniform distribution on [0,2π)[0, 2\pi) and c("\n\n", "Sp1:=xinRp:x=1S^{p-1}:={x\\in R^p:||x||=1}"), p2p\ge 2.

r_unif_cir(n, M = 1L, sorted = FALSE) r_unif_sph(n, p, M = 1L)

Arguments

  • n: sample size.
  • M: number of samples of size n. Defaults to 1.
  • sorted: return each circular sample sorted? Defaults to FALSE.
  • p: integer giving the dimension of the ambient space RpR^p that contains Sp1S^{p-1}.

Returns

  • r_unif_cir: a matrix of size c(n, M) with M random samples of size n of uniformly-generated circular data on [0,2π)[0, 2\pi).
  • r_unif_sph: an array of size c(n, p, M) with M random samples of size n of uniformly-generated directions on Sp1S^{p-1}.

Examples

# A sample on [0, 2*pi) n <- 5 r_unif_cir(n = n) # A sample on S^1 p <- 2 samp <- r_unif_sph(n = n, p = p) samp rowSums(samp^2) # A sample on S^2 p <- 3 samp <- r_unif_sph(n = n, p = p) samp rowSums(samp^2)
  • Maintainer: Eduardo García-Portugués
  • License: GPL-3
  • Last published: 2024-05-24