This document illustrates how to sample \(\alpha\)-shapes from a true probability
distribution in three dimensions. The main function within the package
to do this is sampling3Dashape
, which generates \(\alpha\)-shapes given the parameters.
Package rgl
is needed for plotting, and plots will show in
a pop out window.
There are several ways to adjust the hierarchical distribution of the function which will be discussed throughout the document. The function requires only parameter \(N\), the number of shapes to be sampled. All other parameters are set to default, and the function samples an \(\alpha\)-shape from the following distribution:
\[\alpha \sim \mathcal{N}_T(\mu=0.25,\sigma=0.5, a=\min(0.1, \tau/4), b=\tau/2)\] \[n | \alpha = n_{c min}(\alpha, \delta=0.05)\] \[x_1, ..., x_n \sim \text{Unif}(\mathcal{M}) \]
where \(n\) the number of points sampled is dependent on the number of points needed to produce a connected shape for a randomly selected \(\alpha\), \(\delta\) is the probability that the generated shape has more than one connected component, and points are selected uniformly from some manifold \(\mathcal{M}\). We could allow the lower bound of the truncated normal distribution of \(\alpha\) to be as small as \(a=0\), however, we set it to \(a= min(0.1, tau/4)\) to prevent computational bottleneck. Bounds of the truncated normal distribution are fixed for the user. Values of \(\tau\) for different underlying manifolds are as follows:
The condition number is not a user adjusted parameter.
For demonstration purposes, we set \(N=1\). The sampling3Dashape
function returns a list of length \(N\)
of those objects.
set.seed(100001)
my_ashape = sampling3Dashape(N=1)
plot(my_ashape[[1]])
#> Device 1 : alpha = 0.2434609
rglwidget()
To make the number of points a random variable in and of itself, we can add a discrete distribution \(\pi\) to \(n | \alpha\). In the code, this discrete distribution is a Poisson distribution with default \(\lambda = 3\). Parameter \(\lambda\) can be adjusted by the user. The distribution from which the new shape is sampled is then given by:
\[\alpha \sim NT(\mu=0.25,\sigma=0.5, a=\min(0.1, \tau/4), b=\tau/2)\] \[n | \alpha = n_{min}(\alpha, \delta=0.05) + \text{Poisson}(\lambda)\] \[x_1, ..., x_n \stackrel{i.i.d.}{\sim} \text{Unif}(\mathcal{M}) \]
To make the code dynamic, set n.noise = TRUE
. This code
is where \(\lambda = 3\).
my_ashape = sampling3Dashape(N=1, n.noise = TRUE)
plot(my_ashape[[1]])
#> Device 1 : alpha = 0.2092051
rglwidget()
Code with the adjustment \(\lambda = 10\):
my_ashape = sampling3Dashape(N=1, n.noise = TRUE, lambda = 10)
plot(my_ashape[[1]])
#> Device 1 : alpha = 0.231029
rglwidget()
We can also change the dependence of \(n\) relative to \(\alpha\). First, we can make \(n\) independent of \(\alpha\) by setting
n.dependent = FALSE
. Then \(n=20\) is the default number of points
used. (If n.noise=TRUE
, then 20 is the minimum number of
points used before adding more based on a Poisson random variable.)
Making \(n\) independent from \(\alpha\) allows for more variation in the
resulting shapes, including the number of connected components. Example
code with independent \(n\) and
noise:
my_ashape = sampling3Dashape(N=1, n.dependent=FALSE, n.noise=TRUE, lambda = 5)
plot(my_ashape[[1]])
#> Device 1 : alpha = 0.2488231
rglwidget()
In the other direction, we can choose to make \(n\) dependent on \(\alpha\) such that the underlying
manifold’s topology is preserved. In the case of a square, this means we
will have one connected component with no holes with probability \(1 - \delta\). Here, it is strict that \(\alpha/2 < \tau\), which defaults to 1.
Note that the smaller \(\tau\) is, the
smaller \(\alpha\) has to be, the more
points which must be sampled, and thus the slower the algorithm. Users
will see the variation in the shapes will lie on the boundaries when
setting nhomology=TRUE
:
my_ashape = sampling3Dashape(N=1, nhomology = TRUE)
#> Warning in sampling3Dashape(N = 1, nhomology = TRUE): Both nhomology and
#> nconnect are true, default to nhomology for choosing n.
plot(my_ashape[[1]])
#> Device 1 : alpha = 0.1794529
rglwidget()