Sampling
StatsBase.sample — Functionsample([rng], object, method)Sample elements or points from geometric object with method. Optionally, specify random number generator rng.
sample([rng], object, nsamples, [weights], replace=false)Generate nsamples samples from spatial object uniformly or using weights, with or without replacement depending on replace option.
Meshes.SamplingMethod — TypeSamplingMethodA method for sampling from geometric objects.
Meshes.DiscreteSamplingMethod — TypeDiscreteSamplingMethodA method for sampling from discrete representations of geometric objects such as meshes or collections of geometries.
Meshes.ContinuousSamplingMethod — TypeContinuousSamplingMethodA method for sampling from continuous representations of geometric objects. In this case, geometric objects are interpreted as a set of points in the embedding space.
Discrete sampling
Meshes.UniformSampling — TypeUniformSampling(size, replace=false)Sample elements uniformly from a given domain/data. Produce a sample of given size with or without replacement depending on the replace option.
Meshes.WeightedSampling — TypeWeightedSampling(size, [weights]; replace=false)Sample elements from a given domain/data using weights. Produce a sample of given size with or without replacement depending on the replace option. By default weights are uniform.
Meshes.BallSampling — TypeBallSampling(radius; [options])A method for sampling isolated elements from a given domain/data according to a norm-ball of given radius.
Options
metric- Metric for the ball (default toEuclidean())maxsize- Maximum size of the resulting sample (default to none)
Continuous sampling
Meshes.RegularSampling — TypeRegularSampling(n1, n2, ..., np)Generate samples regularly using n1 points along the first parametric dimension, n2 points along the second parametric dimension, ..., np points along the last parametric dimension.
Examples
Sample sphere regularly with 360 longitudes and 180 latitudes:
sample(Sphere((0,0,0), 1), RegularSampling(360, 180))Meshes.HomogeneousSampling — TypeHomogeneousSampling(size)Generate sample of given size from geometric object according to a homogeneous density.
Meshes.MinDistanceSampling — TypeMinDistanceSampling(α, ρ=0.65, δ=100, metric=Euclidean())Generate sample from geometric object such that all pairs of points are at least α units of distance away from each other. Optionally specify the relative radius ρ for the packing pattern, the oversampling factor δ and the metric.
This method is sometimes referred to as Poisson disk sampling or blue noise sampling in the computer graphics community.
References
- Lagae, A. & Dutré, P. 2007. A Comparison of Methods for Generating Poisson Disk Distributions
- Bowers et al. 2010. Parallel Poisson disk sampling with spectrum analysis on surfaces
- Medeiros et al. 2014. Fast adaptive blue noise on polygonal surfaces