unif_cap {sphunif} | R Documentation |
Uniform spherical cap distribution
Description
Density, simulation, and associated functions for a uniform
distribution within a spherical cap of angle about
a direction
on
,
. The
density at
is given by
where
is the projected radius of the spherical cap about
,
is the surface area of
, and
is the projected uniform distribution (see
p_proj_unif
).
The angular function of the uniform cap distribution is
. The associated
projected density is
.
Usage
d_unif_cap(x, mu, angle = pi/10)
c_unif_cap(p, angle = pi/10)
r_unif_cap(n, mu, angle = pi/10)
p_proj_unif_cap(x, p, angle = pi/10)
q_proj_unif_cap(u, p, angle = pi/10)
d_proj_unif_cap(x, p, angle = pi/10, scaled = TRUE)
r_proj_unif_cap(n, p, angle = pi/10)
Arguments
x |
locations to evaluate the density or distribution. For
|
mu |
the directional mean |
angle |
angle |
p |
integer giving the dimension of the ambient space |
n |
sample size, a positive integer. |
u |
vector of probabilities. |
scaled |
whether to scale the angular function by the normalizing
constant. Defaults to |
Value
Depending on the function:
-
d_unif_cap
: a vector of lengthnx
or1
with the evaluated density atx
. -
r_unif_cap
: a matrix of sizec(n, p)
with the random sample. -
c_unif_cap
: the normalizing constant. -
p_proj_unif_cap
: a vector of lengthx
with the evaluated distribution function atx
. -
q_proj_unif_cap
: a vector of lengthu
with the evaluated quantile function atu
. -
d_proj_unif_cap
: a vector of sizenx
with the evaluated angular function. -
r_proj_unif_cap
: a vector of lengthn
containing simulated values from the cosines density associated to the angular function.
Author(s)
Alberto Fernández-de-Marcos and Eduardo García-Portugués.
Examples
# Simulation and density evaluation for p = 2
mu <- c(0, 1)
angle <- pi / 5
n <- 1e2
x <- r_unif_cap(n = n, mu = mu, angle = angle)
col <- viridisLite::viridis(n)
r_noise <- runif(n, 0.95, 1.05) # Perturbation to improve visualization
color <- col[rank(d_unif_cap(x = x, mu = mu, angle = angle))]
plot(r_noise * x, pch = 16, col = color, xlim = c(-1, 1), ylim = c(-1, 1))
# Simulation and density evaluation for p = 3
mu <- c(0, 0, 1)
angle <- pi / 5
x <- r_unif_cap(n = n, mu = mu, angle = angle)
color <- col[rank(d_unif_cap(x = x, mu = mu, angle = angle))]
scatterplot3d::scatterplot3d(x, size = 5, xlim = c(-1, 1), ylim = c(-1, 1),
zlim = c(-1, 1), color = color)
# Simulated data from the cosines density
n <- 1e3
p <- 3
angle <- pi / 3
hist(r_proj_unif_cap(n = n, p = p, angle = angle),
breaks = seq(cos(angle), 1, l = 10), probability = TRUE,
main = "Simulated data from proj_unif_cap", xlab = "t", xlim = c(-1, 1))
t <- seq(-1, 1, by = 0.01)
lines(t, d_proj_unif_cap(x = t, p = p, angle = angle), col = "red")